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 FIR滤波器算法设计与实现(利用库函数firdec()
  • ¥15 利用单片机产生正弦信号,来测量差分放大电路放大倍数和共模放大倍数的思路和仿真
  • ¥60 关于mavlink的论文咨询
  • ¥66 定制开发肯德基自动化网站下单软件
  • ¥15 中科院研发的TextMind(文心)
  • ¥20 vscode虚拟环境依赖包未安装
  • ¥15 odoo17关于owl开发js代码问题
  • ¥15 光纤中多普勒频移公式的推导
  • ¥15 怎么制作一个人脸识别门禁系统
  • ¥20 大华dss监控平台网络关闭登不进去