D.I*_*dis 15 php laravel laravel-5
我正在进行我的第一个laravel项目,我正面临着一个问题.
如果您有使用laravel的经验,您可能知道通过调用php artisan make:auth您将获得一个处理登录和注册的预定义机制.
设置此机制以理解一些常用单词以使整个过程自动化.
在我的情况下发生的问题是我正在使用oracle db并且它不会让我有一个名为的表列,password因为它是一个系统关键字,并且在尝试插入用户时会抛出错误.
到目前为止,我已经尝试将我的password专栏更改为passwd,并按预期在我的注册表单中工作.用户行已成功插入,我的页面被重定向到/ home.

但是当我尝试注销然后重新登录时,我收到此错误,告诉我我的凭据不正确.

至于我的代码,我改变了我的意思RegisterController.php,它需要用户名而不是电子邮件
protected function validator(array $data)
{
return Validator::make($data, [
'username' => 'required|max:50|unique:ECON_USERS',
'passwd' => 'required|min:6|confirmed',
]);
}
protected function create(array $data)
{
return User::create([
'username' => $data['username'],
'passwd' => bcrypt($data['passwd'])
]);
}
Run Code Online (Sandbox Code Playgroud)
用户$可填写
protected $fillable = [
'username', 'passwd'
];
Run Code Online (Sandbox Code Playgroud)
我猜测Auth正在尝试验证,email而不是usernameAuth正在搜索password而不是passwd
Gau*_*rav 25
为了username代替email,您可以在LoginController.php中覆盖username()
/**
* Get the login username to be used by the controller.
*
* @return string
*/
public function username()
{
return 'username';
}
Run Code Online (Sandbox Code Playgroud)
而passwd不是password,您可以在App\User.php中定义一个访问者
/**
* Get the password for the user.
*
* @return string
*/
public function getAuthPassword()
{
return $this->passwd;
}
Run Code Online (Sandbox Code Playgroud)
login.blade.php:替换email输入username但不更改输入的名称password.
| 归档时间: |
|
| 查看次数: |
25314 次 |
| 最近记录: |