Not sure if this will work, but remember to add this to your
AppController file, since your password field is not "password" but
"key".

var $components = array('Session',
            'Auth'=> array(
                    'authenticate' => array(
                            'Form' => array(
                                    'fields' => array('username' =>
'email', 'password' => 'key')
                            )
                    )
            )
    );


Also make sure your database field is large enough to fit the whole
password. SHA1 hashes are 20 bytes long.



On Nov 7, 8:38 pm, Keyner <[email protected]> wrote:
> I followed what you did but I can not work.
> I have 2 fields for authentication
> emailkey
> How do I resolve this?
> I did this at the controller
> public function ingresar() {
>                 
> $this->set('usersss',AuthComponent::password($this->data['User']
> ['key']));
>                 if ($this->Auth->login())
>             {
>                 $this->redirect($this->Auth->redirect());
>             } else
>             {
>                 $this->Session->setFlash(__('Invalid username or
> password, try again'));
>             }
>         }
> and the view throws me the following
> "c984aed014aec7623a54f0591da07a85fd4b762d1"
> however, in the model
> public function beforeSave () {if (isset ($ this->data [$ this->name]
> ['key'])) {$this->data ['User']['key'] = AuthComponent::password(data
> ['User'] ['key']);}return true;}
> and the data recorded "c984aed014aec7623a54f0591da07a85fd4b762d"
> without the "1" at the end.
> What do I do?
> On 7 nov, 20:40, Sandy Wilkins <[email protected]> wrote:
>
>
>
>
>
>
>
> > Ok, got it to work! I guess its a combination of all these
> > suggestions, but it finally didloginwhen I commented the following:
>
> > $this->Auth->userModel = 'Users';
> > // $this->Auth->fields = array('username' => 'email', 'password' =>
> > 'password');  <-- commented out
> > $this->Auth->loginAction = array('controller' => 'users', 'action' =>
> > 'login');
> > $this->Auth->loginRedirect = array('controller' => 'hotels', 'action'
> > => 'dashboard');
> > $this->Auth->logoutRedirect = array('controller' => 'users', 'action'
> > => 'login');
>
> > I added this to my code, as I explained before:
>
> > var $components = array('Session',
> >             'Auth'=> array(
> >                     'authenticate' => array(
> >                             'Form' => array(
> >                                     'fields' => array('username' =>
> > 'email')
> >                             )
> >                     )
> >             )
> >     );
>
> > Thanks John and Andras for your help!  Really appreciated!
>
> > On Nov 7, 7:29 pm, Sandy Wilkins <[email protected]> wrote:
>
> > > I commented out all the code in theloginmethod, and when I submit
> > > the form I see no sql queries in the bottom of the layout. I'm just
> > > sent back to the sameloginform, no info below.
>
> > > On Nov 6, 9:52 am, Andras Kende <[email protected]> wrote:
>
> > > > The code looks good,  You could comment out the 
> > > > $this->redirect($this->Auth->redirect()); fromloginmethod
> > > > and check the sql dump to see if the mysql query is correct …
>
> > > > Andras Kende
>
> > > > On Nov 5, 2011, at 9:01 PM, Sandy Wilkins wrote:
>
> > > > > I'm trying to get a simpleloginform to work using CakePHP 2.0...
> > > > > just Auth, no ACLs for now.
>
> > > > > I'm able to see the form and enter the email and password as they are
> > > > > in the database, but I just get returned to the form and the flash
> > > > > error message is displayed. Here is my code:
>
> > > > > **AppController:**
> > > > >    class AppController extends Controller
> > > > >    {
> > > > >        function beforeFilter()
> > > > >        {
> > > > >            $this->Auth->userModel = 'Users';
> > > > >            $this->Auth->fields = array('username' => 'email',
> > > > > 'password' => 'password'); //have to put both, even if we're just
> > > > > changing one
> > > > >            $this->Auth->loginAction = array('controller' => 'users',
> > > > > 'action' => 'login');
> > > > >            $this->Auth->loginRedirect = array('controller' =>
> > > > > 'hotels', 'action' => 'dashboard');
> > > > >            $this->Auth->logoutRedirect = array('controller' =>
> > > > > 'users', 'action' => 'login');
> > > > >        }
> > > > >    }
>
> > > > > **login.ctp:**
> > > > >    <?php
> > > > >        echo $this->Form->create(); //'User', array('action' =>
> > > > > 'login'));
> > > > >        echo $this->Form->input('email');
> > > > >        echo $this->Form->input('password');
> > > > >        echo $this->Form->end('Login');
> > > > >    ?>
>
> > > > > **UsersController:**
> > > > >    <?php
>
> > > > >    class UsersController extends AppController
> > > > >    {
> > > > >        var $name = 'Users';
> > > > >        var $helpers = array('Html','Form');
> > > > >        var $components = array('Auth','Session');
>
> > > > >        function beforeFilter()
> > > > >        {
> > > > >            $this->Auth->allow("logout");
> > > > >            parent::beforeFilter();
> > > > >        }
>
> > > > >        function index() { } //Redirects tologin()
>
> > > > >        functionlogin()
> > > > >        {
> > > > >            if ($this->Auth->login())
> > > > >            {
> > > > >                $this->redirect($this->Auth->redirect());
> > > > >            } else
> > > > >            {
> > > > >                $this->Session->setFlash(__('Invalid username or
> > > > > password, try again'));
> > > > >            }
> > > > >        }
>
> > > > >        function logout()
> > > > >        {
> > > > >            $this->redirect($this->Auth->logout());
> > > > >        }
> > > > >    }
> > > > >    ?>
>
> > > > > I appreciate any help with this. Thanks!
>
> > > > > --
> > > > > Our newest site for the community: CakePHP Video 
> > > > > Tutorialshttp://tv.cakephp.org
> > > > > Check out the new CakePHP Questions 
> > > > > sitehttp://ask.cakephp.organdhelpotherswith their CakePHP related 
> > > > > questions.
>
> > > > > To unsubscribe from this group, send email to
> > > > > [email protected] For more options, visit this 
> > > > > group athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to