简体   繁体   English

Laravel 5.7身份验证问题无法访问

[英]Laravel 5.7 Auth Problem can't get access

i can't get access to my login auth even if everything was fine until i did a migration refresh to start from 0 testing everything if it was fine. 即使一切正常,我也无法访问我的登录身份验证,直到我进行迁移刷新以从0开始测试一切是否正常为止。 i created a user but when i try to login it show just error as if my data was incorrect. 我创建了一个用户,但是当我尝试登录时,仅显示错误,好像我的数据不正确。

    public function login(Request $request) {
        if($request->isMethod('post')){

            $data = $request->input();
        if (Auth::attempt(['email'=>$data['email'],'password'=>$data['password']])) {
                return redirect('/admin/dashboard');

    }else{
       return redirect('admin/')->with ('msg_error','Pseudo ou mot de passe invalide');

    }
}

        return view ('admin.admin_login');
    }

My data from PMA 我来自PMA的数据

this is my login form 这是我的登录表格

    <form id="loginform" class="form-vertical" method="post" action="{{ url('admin') }} ">@csrf
        <div class="control-group">
            <div class="controls">
                <div class="main_input_box">
                    <span class="add-on bg_lg"><i class="icon-user"> </i></span><input type="email" name="email" placeholder="Utulisateur" />
                </div>
            </div>
        </div>
        <div class="control-group">
            <div class="controls">
                <div class="main_input_box">
                    <span class="add-on bg_ly"><i class="icon-lock"></i></span><input type="password" name="password" placeholder="Mot de Passe" />
                </div>
            </div>
        </div>
        <div class="form-actions">
            <span class="pull-left"><a href="#" class="flip-link btn btn-info" id="to-recover">Mot de passe oublié ?</a></span>
            <span class="pull-right"><input type="submit" value="Se connecter" class="btn btn-success" /></span>
        </div>
    </form>

The user Creation file : 用户创建文件:

    $user = new User;
    $user->name = $data['name'];
    $user->role = $data['role'];
    $user->email = $data['email'];
    $user->password = bcrypt($data['password']);
    $user->save(); 

Data from input : 来自输入的数据:

array(3) {
  ["_token"]=>
  string(40) "2h4nA3WuLSlWfpInCH45eUZqtyvHWEg5K7aYWC83"
  ["email"]=>
  string(14) "test@email.com"
  ["password"]=>
  string(6) "000000"
}

and data after using hash check 和使用哈希检查后的数据

    object(App\User)#266 (27) {
  ["fillable":protected]=>
  array(6) {
    [0]=>
    string(4) "name"
    [1]=>
    string(5) "email"
    [2]=>
    string(5) "level"
    [3]=>
    string(8) "password"
    [4]=>
    string(6) "status"
    [5]=>
    string(15) "activation_code"
  }
  ["hidden":protected]=>
  array(2) {
    [0]=>
    string(8) "password"
    [1]=>
    string(14) "remember_token"
  }
  ["connection":protected]=>
  string(5) "mysql"
  ["table":protected]=>
  NULL
  ["primaryKey":protected]=>
  string(2) "id"
  ["keyType":protected]=>
  string(3) "int"
  ["incrementing"]=>
  bool(true)
  ["with":protected]=>
  array(0) {
  }
  ["withCount":protected]=>
  array(0) {
  }
  ["perPage":protected]=>
  int(15)
  ["exists"]=>
  bool(true)
  ["wasRecentlyCreated"]=>
  bool(false)
  ["attributes":protected]=>
  array(9) {
    ["id"]=>
    int(1)
    ["name"]=>
    string(5) "Test1"
    ["role"]=>
    string(5) "Admin"
    ["email"]=>
    string(14) "test@email.com"
    ["email_verified_at"]=>
    string(19) "2018-10-21 00:00:00"
    ["password"]=>
    string(60) "$2y$10$1FRa6tZz9Q.NycSVEickte/zBXfLjSlONH0Byiu363bBtQZVXLbwS"
    ["remember_token"]=>
    NULL
    ["created_at"]=>
    string(19) "2018-10-21 11:39:51"
    ["updated_at"]=>
    string(19) "2018-10-21 11:39:51"
  }
  ["original":protected]=>
  array(9) {
    ["id"]=>
    int(1)
    ["name"]=>
    string(5) "Test1"
    ["role"]=>
    string(5) "Admin"
    ["email"]=>
    string(14) "test@email.com"
    ["email_verified_at"]=>
    string(19) "2018-10-21 00:00:00"
    ["password"]=>
    string(60) "$2y$10$1FRa6tZz9Q.NycSVEickte/zBXfLjSlONH0Byiu363bBtQZVXLbwS"
    ["remember_token"]=>
    NULL
    ["created_at"]=>
    string(19) "2018-10-21 11:39:51"
    ["updated_at"]=>
    string(19) "2018-10-21 11:39:51"
  }
  ["changes":protected]=>
  array(0) {
  }
  ["casts":protected]=>
  array(0) {
  }
  ["dates":protected]=>
  array(0) {
  }
  ["dateFormat":protected]=>
  NULL
  ["appends":protected]=>
  array(0) {
  }
  ["dispatchesEvents":protected]=>
  array(0) {
  }
  ["observables":protected]=>
  array(0) {
  }
  ["relations":protected]=>
  array(0) {
  }
  ["touches":protected]=>
  array(0) {
  }
  ["timestamps"]=>
  bool(true)
  ["visible":protected]=>
  array(0) {
  }
  ["guarded":protected]=>
  array(1) {
    [0]=>
    string(1) "*"
  }
  ["rememberTokenName":protected]=>
  string(14) "remember_token"
}
bool(false)
object(App\User)#279 (27) {
  ["fillable":protected]=>
  array(6) {
    [0]=>
    string(4) "name"
    [1]=>
    string(5) "email"
    [2]=>
    string(5) "level"
    [3]=>
    string(8) "password"
    [4]=>
    string(6) "status"
    [5]=>
    string(15) "activation_code"
  }
  ["hidden":protected]=>
  array(2) {
    [0]=>
    string(8) "password"
    [1]=>
    string(14) "remember_token"
  }
  ["connection":protected]=>
  string(5) "mysql"
  ["table":protected]=>
  NULL
  ["primaryKey":protected]=>
  string(2) "id"
  ["keyType":protected]=>
  string(3) "int"
  ["incrementing"]=>
  bool(true)
  ["with":protected]=>
  array(0) {
  }
  ["withCount":protected]=>
  array(0) {
  }
  ["perPage":protected]=>
  int(15)
  ["exists"]=>
  bool(true)
  ["wasRecentlyCreated"]=>
  bool(false)
  ["attributes":protected]=>
  array(9) {
    ["id"]=>
    int(1)
    ["name"]=>
    string(5) "Test1"
    ["role"]=>
    string(5) "Admin"
    ["email"]=>
    string(14) "test@email.com"
    ["email_verified_at"]=>
    string(19) "2018-10-21 00:00:00"
    ["password"]=>
    string(60) "$2y$10$1FRa6tZz9Q.NycSVEickte/zBXfLjSlONH0Byiu363bBtQZVXLbwS"
    ["remember_token"]=>
    NULL
    ["created_at"]=>
    string(19) "2018-10-21 11:39:51"
    ["updated_at"]=>
    string(19) "2018-10-21 11:39:51"
  }
  ["original":protected]=>
  array(9) {
    ["id"]=>
    int(1)
    ["name"]=>
    string(5) "Test1"
    ["role"]=>
    string(5) "Admin"
    ["email"]=>
    string(14) "test@email.com"
    ["email_verified_at"]=>
    string(19) "2018-10-21 00:00:00"
    ["password"]=>
    string(60) "$2y$10$1FRa6tZz9Q.NycSVEickte/zBXfLjSlONH0Byiu363bBtQZVXLbwS"
    ["remember_token"]=>
    NULL
    ["created_at"]=>
    string(19) "2018-10-21 11:39:51"
    ["updated_at"]=>
    string(19) "2018-10-21 11:39:51"
  }
  ["changes":protected]=>
  array(0) {
  }
  ["casts":protected]=>
  array(0) {
  }
  ["dates":protected]=>
  array(0) {
  }
  ["dateFormat":protected]=>
  NULL
  ["appends":protected]=>
  array(0) {
  }
  ["dispatchesEvents":protected]=>
  array(0) {
  }
  ["observables":protected]=>
  array(0) {
  }
  ["relations":protected]=>
  array(0) {
  }
  ["touches":protected]=>
  array(0) {
  }
  ["timestamps"]=>
  bool(true)
  ["visible":protected]=>
  array(0) {
  }
  ["guarded":protected]=>
  array(1) {
    [0]=>
    string(1) "*"
  }
  ["rememberTokenName":protected]=>
  string(14) "remember_token"
}
bool(false)

i don't know where is the problem 我不知道问题出在哪里

According to the false return of Hash::check('000000', $user->password); 根据Hash::check('000000', $user->password);的错误返回Hash::check('000000', $user->password); , the password is not a hashed value of 000000 in the database. ,密码不是数据库中000000的哈希值。

You can reset the password with 您可以使用

$user->update(['password' => bcrypt('000000')]);

Bcrypt is a helper function for Hash::make. Bcrypt是Hash :: make的帮助函数。 Using artisan tinker will make this easy as it provides you an interactive console to run commands. 使用artisan tinker将使此过程变得容易,因为它为您提供了一个交互式控制台来运行命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM