[英]Laravel 5.2 authorization form POST
I am new to Laravel in general and working with version 5.2. 我是Laravel的新手,正在使用5.2版。 Basically I needed to add 2 fields to my users table.
基本上,我需要向用户表中添加2个字段。 Opposed to
name
I have first_name
and last_name
. 与
name
相反,我有first_name
和last_name
。 I dont want to use the auth views set up in Laravel so I am just looking where to POST my user login form to. 我不想使用在Laravel中设置的身份验证视图,所以我只是在寻找将用户登录表单发布到哪里。
I found some stuff from 5.1 that said to method="POST" action="/auth/login"
and have the route Route::post('auth/login', 'Auth\\AuthController@postLogin');
我从5.1中找到了一些对
method="POST" action="/auth/login"
说的东西,并具有Route::post('auth/login', 'Auth\\AuthController@postLogin');
but that part of the controller seems to be gone. 但是控制器的那一部分似乎不见了。
I see the validator and create functions (which I used to create the user doing a POST to the Create method) 我看到了验证器并创建了函数(我用来创建对POST方法执行POST的用户)
protected function validator(array $data)
{
return Validator::make($data, [
'first_name' => 'required|max:255',
'last_name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
return User::create([
'last_name' => $data['first_name'],
'last_name' => $data['first_name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
You think there would be an easy way to run this form in 5.2 like there was in 5.1 您认为像在5.1中一样,有一种在5.2中运行此表单的简单方法
I am going to leave the question but I ended up doing a POST to a method inside a controller and adding this 我要离开这个问题,但是我最终对控制器内部的方法进行了POST并添加了这个
use Auth; //add to top of controller
//inside the class
public function authenticate()
{
$email = ($_POST["email"]);
$password = ($_POST["password"]);
if (Auth::attempt(['email' => $email, 'password' => $password])) {
// Authentication passed...
return redirect()->intended('dashboard');
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.