auth::artempt does not work on laravel4

Asked 2 years ago, Updated 2 years ago, 42 views

$input=[
    'mail' = > Input::get('mail'),
    'password' = > Input::get('password'),
 ];

 if(Auth::attempt($input)){
    echo 'Success';
 } else{
    echo 'Failed';
 }

Unable to authenticate
Below is User.php. Where else should I look?

<?php
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemovableInterface;

class User extensions Eloquent implements UserInterface, RemovableInterface {
    protected$table='users';
    public function getAuthIdentifier(){
        return$this->getKey();
    }
    public function getRememberToken(){
        return$this->remember_token;
    }
    public function getAuthPassword(){
        return $this->password;
    }
    public function setRememberToken($value){
        $this->remember_token=$value;
    }
    public function getRememberTokenName(){
        return 'remember_token';
    }
    public function getReminderEmail(){
        return$this->email;
    }
}

php laravel

2022-09-30 19:28

1 Answers

$input=[
    'email' = > Input::get('mail'),
    'password' = > Input::get('password'),
 ];

Please change mail to email as above code.
You may also need to verify that the password column in the database is at least 60 characters long.
Please hash your password when you register.Do not hash during authentication

$user->password=Hash::make(Input::get('password'));


2022-09-30 19:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.