*/Route::post('login',function(){//get the credentials from input$creds=array('username'=>Input::get('username'),'password'=>Input::get('password'))// successful login attempt - redirect to the intended page, fallback to the '/' route if no intended pageif(Auth::attempt($creds,true...
// redirect the user back to the intended page // or defaultpage if there isn't one if (Auth::attempt(['email' => $email, 'password' => $password])) { return Redirect::intended('defaultpage'); } Laravel 3(更老的答案) 你可以这样实现它: Route::filter('auth', function() { //...
session()->flash('success', '欢迎回来!');$fallback= route('users.show', Auth::user());returnredirect()->intended($fallback); }else{ session()->flash('danger', '很抱歉,您的邮箱和密码不匹配');returnredirect()->back()->withInput(); } }...
Redirect::intended('/')这个方法的意思是跳转到之前的页面,如果像上面那样使用了Redirect::guest()方法,那么intended这里就会跳转到那时候的url,而它的参数只是一个默认值,再没有记录历史url的时候会跳转到'/'。 还可以继续优化,比如我们不应当在BaseController中进行Auth::check,我们可以利用Route::filter,在请求之...
return redirect('/vien')->withInput(); 而我们有时候需要登录后跳转到上一个访问的页面,在laravel的auth模块中其实是这样定义的: return redirect()->intended(); 在路由中直接跳转 动态URL跳转 Route::get('article/{id}', function($id){ return Redirect::to($id, 301); ...
您的代码中可能存在导致重定向问题的问题。修改的代码:
{$remember=$request->input('remember');}//如果要使用记住密码的话,需要在数据表里有remember_token字段if(Auth::attempt(['username'=>$name,'password'=>$password],$remember)){returnredirect()->intended('/');}returnredirect('login')->withInput($request->except('password'))->with('msg','...
最近在一个项目中需要实现一个多字段登录功能,简单来说就是可以使用用户名、邮箱或手机号任意一种方式...
1、Auth::attempt 输入的两个参数,第一个是个函数,key 和 value 分别对应数据库users表字段名和对应的输入值。第二个参数是是否选择“remember_me”这个选项。2、Auth::attempt 返回true 说明验证通过。 用Redirect::intended() 方法可已经将页面转向登陆前的页面。里面输入的参数是该页面无效时的备用地址。
?: redirect()->intended($this->redirectPath()); } /** * The user has been authenticated. * * @param \Illuminate\Http\Request $request * @param mixed $user * @return mixed */ protected function authenticated(Request $request, $user) ...