doubu4406 2015-08-28 11:21
浏览 64
已采纳

Laravel 4.2 Auth ::尝试失败

Problem: returns false every time i try to Auth::attempt()

myUsersModel.php

<?php
use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;

class myUsersModel extends Eloquent implements UserInterface, RemindableInterface{

use UserTrait, RemindableTrait;

protected $table = 'myUsersTable';
protected $primaryKey = 'primary_key';
public $timestamps = false;
protected $increments = 'primary_key';
protected $fillable = array(
   'user',           //this is like username
   'password',       //this one contains hashed password values
   'userlevel',
   'remember_token',
);
   protected $hidden = array('password');
}

myController.php

$attemptData = array(
    'user' => Input::get('textBoxInput'),
    'password' => Input::get('passwordInput')
);
Auth::attempt($attemptData);
return var_dump(Auth::check());

auth.php

'driver' => 'eloquent',
'model' => 'myUsersModel',
'table' => 'myUsersTable'

Another notes :
1. My remember token is nullable varchar(100)
2. My password field is varchar(60)
3. I can get form values with dd(Input:all())
4. In my database, i have both hashed and non-hashed password values, different for each user. But both cannot log in.

Thanks.

  • 写回答

1条回答 默认 最新

  • dongza1708 2015-08-28 14:14
    关注

    I haven't posted my entire customized model and controller, but my model has an email field like 'user_e_mail' and to meet the requirements of my authentication rules, which needs to be checked.

    Here's the thing, i had to override getReminderEmail() method under myUsersModel model.

    public function getReminderEmail() {
        return $this->user_e_mail;
    }
    

    So now i am able to authenticate.

    Thanks.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器