{"id":4108,"date":"2012-02-03T18:31:45","date_gmt":"2012-02-03T10:31:45","guid":{"rendered":"http:\/\/wp.chunhsin.idv.tw\/?p=4108"},"modified":"2012-02-03T18:31:55","modified_gmt":"2012-02-03T10:31:55","slug":"%e9%9a%a8%e6%89%8b%e7%ad%86%e8%a8%982012-2-3","status":"publish","type":"post","link":"https:\/\/wp.chunhsin.idv.tw\/?p=4108","title":{"rendered":"\u96a8\u624b\u7b46\u8a182012-2-3"},"content":{"rendered":"<p>#zend\u7684controller\u7684_redirect\u4e4b\u5f8c\u7684\u6558\u8ff0\u4e0d\u6703\u57f7\u884c<\/p>\n<p>#Zend_Auth\u7684\u4f7f\u7528\u8005\u9a57\u8b49\u662f\u900f\u904e\u5be6\u4f5cZend_Auth_Adapter_Interface\u7684\u985e\u5225\u4f86\u9032\u884c\uff0c\u5be6\u969b\u4e0a\u662f\u5be6\u4f5cZend_Auth_Adapter_Interface\u4ecb\u9762\u88e1\u7684authenticate\u65b9\u6cd5\uff0c\u800c\u4e14\u9019\u500bauthenticate\u65b9\u6cd5\u5fc5\u9808\u50b3\u56deZend_Auth_Result\u7684\u5be6\u9ad4\u3002<!--more--><\/p>\n<p>\u4e00\u822c\u662f\u900f\u904e\u8cc7\u6599\u5eab\u8cc7\u6599\u9032\u884c\u4f7f\u7528\u8005\u9a57\u8b49\uff0cZF\u6709\u5be6\u4f5c\u4e00\u500bZend_Auth_Adapter_DbTable\u985e\u5225\u4f86\u64cd\u4f5c\u3002\u5728\u9032\u884c\u9a57\u8b49\u4e4b\u524d\u5fc5\u9808\u5148\u6307\u5b9a\u8cc7\u6599\u5eab\u9023\u7dda\u7269\u4ef6\u3001\u8cc7\u6599\u8868\u540d\u7a31\u3001\u5e33\u865f\u6b04\u4f4d\u3001\u5bc6\u78bc\u6b04\u4f4d\u53ca\u5982\u4f55\u8655\u7406\u5f9e\u8868\u55ae\u50b3\u5165\u7684\u5bc6\u78bc\uff0c\u9019\u53ef\u4ee5\u4f9d\u5e8f\u662fZend_Auth_Adapter_DbTable\u985e\u5225\u7684\u5efa\u69cb\u53c3\u6578\uff0c\u4e5f\u53ef\u4ee5\u7a0d\u5f8c\u900f\u904esetTableName\u3001setTableName\u3001setCredentialColumn\u53casetCredentialTreatment\u7b49\u65b9\u6cd5\u4f86\u6307\u5b9a\u3002\u4f8b\u5982<\/p>\n<blockquote><p>$authAdapter = new Zend_Auth_Adapter_DbTable(<\/p>\n<p style=\"padding-left: 120px;\">$dbAdapter,\u00a0 \/\/\u8cc7\u6599\u5eab\u9023\u7dda\u7269\u4ef6<\/p>\n<p style=\"padding-left: 120px;\">&#8216;users&#8217;,\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/\u4f7f\u7528\u8005\u5e33\u865f\u8cc7\u6599\u8868<\/p>\n<p style=\"padding-left: 120px;\">&#8216;username&#8217;,\u00a0\u00a0\u00a0 \/\/\u5e33\u865f\u6b04\u4f4d\u540d\u7a31<\/p>\n<p style=\"padding-left: 120px;\">&#8216;password&#8217; , \u00a0 \/\/\u5bc6\u78bc\u6b04\u4f4d\u540d\u7a31<\/p>\n<p style=\"padding-left: 120px;\">&#8216;md5(?)&#8217;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/\u8655\u7406\u50b3\u5165\u5bc6\u78bc\u7684\u65b9\u6cd5\uff0c\u975e\u5fc5\u8981<\/p>\n<p style=\"padding-left: 90px;\">);<\/p>\n<p>\/\/ &#8230;or configure the instance with setter methods<\/p>\n<p>$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);<\/p>\n<p>$authAdapter-&gt;setTableName(&#8216;users&#8217;)<\/p>\n<p style=\"padding-left: 90px;\">-&gt;setIdentityColumn(&#8216;username&#8217;)\u00a0\u00a0 \u00a0 \/\/\u5e33\u865f\u6b04\u4f4d\u540d\u7a31<\/p>\n<p style=\"padding-left: 90px;\">-&gt;setCredentialColumn(&#8216;password&#8217;) \/\/\u5bc6\u78bc\u6b04\u4f4d\u540d\u7a31<\/p>\n<p style=\"padding-left: 90px;\">-&gt;setCredentialTreatment(&#8216;md5(?)&#8217;);\u00a0 \/\/\u8655\u7406\u50b3\u5165\u5bc6\u78bc\u7684\u65b9\u6cd5\uff0c\u975e\u5fc5\u8981<\/p>\n<\/blockquote>\n<p>\u4e0a\u8ff0\u300cmd5(?)\u300d\u5be6\u969b\u4e0a\u662f\u5c07\u50b3\u5165\u7684\u5bc6\u78bc\u503c\u5957\u7528\u5230?\u7684\u4f4d\u7f6e\uff0c\u82e5\u4e0d\u8a2d\u6b64\u9805\u76ee\uff0c\u5247\u4ee3\u8868\u4f7f\u7528\u539f\u59cb\u50b3\u5165\u5bc6\u78bc\u53bb\u505a\u6bd4\u5c0d\u3002\u6b64\u8a2d\u5b9a\u9084\u53ef\u4ee5\u505a\u9032\u968e\u7684\u64cd\u4f5c\uff0c\u4f8b\u5982\uff0c\u82e5\u662f\u8981\u900f\u904eactivate\u6b04\u4f4d\u4f86\u63a7\u5236\u4f7f\u7528\u8005\u5e33\u865f\u7684\u555f\u7528\u8207\u5426\uff0c\u5247\u6b64\u9805\u76ee\u53ef\u4ee5\u8a2d\u70bamd5(?) and activate = 1<\/p>\n<p>\u81f3\u65bc\u5f9e\u8868\u55ae\u50b3\u4f86\u7684\u5e33\u865f\u53ca\u5bc6\u78bc\uff0c\u5247\u900f\u904esetIdentity\u53casetCredential\u4f86\u6307\u5b9a\u3002\u4f8b\u5982<\/p>\n<blockquote><p>$authAdapter-&gt;setIdentity($_POST[&#8216;username&#8217;])<\/p>\n<p style=\"padding-left: 90px;\">-&gt;setCredential($_POST[&#8216;password&#8217;]);<\/p>\n<\/blockquote>\n<p>\u539f\u59cb\u8cc7\u6599\u8acb\u898b\uff1a<a title=\"zend framework\" href=\"$authAdapter     -&gt;setIdentity('my_username')     -&gt;setCredential('my_password') ;\" target=\"_blank\">http:\/\/framework.zend.com\/manual\/en\/zend.auth.adapter.dbtable.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>#zend\u7684controller\u7684_redirect\u4e4b\u5f8c\u7684\u6558\u8ff0\u4e0d\u6703\u57f7\u884c #Zend_Auth\u7684\u4f7f\u7528\u8005\u9a57\u8b49\u662f\u900f\u904e &hellip; <a href=\"https:\/\/wp.chunhsin.idv.tw\/?p=4108\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008\u96a8\u624b\u7b46\u8a182012-2-3\u3009<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[313],"class_list":["post-4108","post","type-post","status-publish","format-standard","hentry","category-freetalking","tag-zend-framework"],"_links":{"self":[{"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/4108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4108"}],"version-history":[{"count":10,"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/4108\/revisions"}],"predecessor-version":[{"id":4128,"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/4108\/revisions\/4128"}],"wp:attachment":[{"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}