In my view file(html)
<form method="POST" tal:attributes="action string:/users/login">
<input type="text" name="email" size="15" maxlength="30" placeholder="your email" /><br />
<input type="password" name="password" size="15" maxlength="15" placeholder="password" /><br />
<input type="submit" value="login" />
</form>
In my AppController.php
public $components = array('RequestHandler', 'Auth' => array( 'authenticate' => array( 'Form' => array('userModel' => 'User', 'fields' => array('username' => 'email', 'password' => 'password'))), 'loginAction' => array('controller' => 'users', 'action' => 'login'));
public function beforeFilter() { $this->Auth->allow('login', 'logout'); }
In my UsersController.php
public function login() { if ($this->request->is('post')) { if ($this->Auth->login()) {
return $this->redirect($this->Auth->redirect()); } else { echo ('failed'); // Always come here...
} } }
public function logout() { $this->Auth->logout(); $this->Session->destroy(); $this->redirect(array('action' => 'login')); }
Could you give some hints, please?
Thank you.
On Sunday, December 21, 2014 4:48:14 PM UTC+9, tech_me wrote:
1. Yes2. Yes3. No any error but just failed(false) at that `if` statement.4. Maybe there is no the same name field in my user table, which is 'email' in html while 'nickname' in table schemaI will have a try soon.Thank you.
On Friday, December 19, 2014 4:55:03 AM UTC+9, John Andersen wrote:Please provide more information on the steps leading up to the error that you get.
1. Is the login form showing?
2. Can you submit the form?
3. Do you get the error back from your login method - wrong e-mail or password?
4. Something else?
Suggest that you at least create the users table and add one user, so that CakePHP has something to work with.
Enjoy, John
On Wednesday, 17 December 2014 14:14:43 UTC+2, tech_me wrote:I posted to SO several days ago, but no expected replies.I am now using PHPTAL which use html instead of ctp files.
Is there anyone who use the html files to cooperate with Cake's authentication?Thanks.
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment