English 中文(简体)
B. 不从事地震的成分2.0
原标题:Auth Component not working on CakePHP 2.0

我对CakePHP1.3的多数甚至所有辅导方法进行了尝试,看来没有在CakePHP 2.0上做工作。

我可以增加用户,打上密码,但标识特征并不奏效。 在我点击原木时,它只是重新启用。 无错误,无。

请和感谢你阅读我的问题。

This my code public function login() {

    if ($this->request->is( post ) )
    {

        if( $this->Auth->login() )
        {

            // the redirect() function in the Auth class redirects us
            // to the url we set up in the AppController.
            return $this->redirect( $this->Auth->redirect());
        }
        else
        {

            $this->Session->setFlash(__( Email or password is incorrect ,true));
        }
    }
}

Thanks, Mahadeva Prasad

问题回答

First of all check how you have hash the password.Also check the field length in database. Preferred - varchar(255) The password will be hash as follows.

class User extends AppModel {
   public function beforeSave($options = array()) {
        $this->data[ User ][ password ] = AuthComponent::password($this->data[ User ][ password ]);
        return true;
   }
} 

同样,当你在宣布部件时使用表格时,也使用这种文字。

public $components = array(
 Auth  => array(
     loginAction  => array(
         controller  =>  users ,
         action  =>  login ,            
    ),       
     authenticate  => array(
         Form  => array(
             fields  => array( username  =>  username )
        )
    )
)
);

详情请见





相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Remotely authenticating client Windows user on demand

Suppose I am writing a server for a particular network protocol. If I know that the client is running on a Windows machine, is it possible for my server to authenticate the Windows user that owns the ...

Role/Permission based forms authorizing/authentication?

While looking into forms authorizing/authentication, I found that it is possible to do role based authorizing by adding an array of roles to a FormsAuthenticationTicket. That way I can write User....

热门标签