2017-06-15 142 views
0

我使用laravel 5.4和auth來登錄,註冊,密碼重置功能一切正常,當我嘗試重置密碼時,它發送一封電子郵件並更改密碼工作良好。新的密碼它重定向到我的主頁,它會自動登錄,但我想要的是更改密碼後重定向到登錄頁面,以便使用可以檢查更改的密碼工作是否正確或不。在laravel重置密碼後重定向到登錄頁面

所以我的問題如何實現這個?

和我ResetPasswordController是

<?php 

namespace App\Http\Controllers\Auth; 

use App\Http\Controllers\Controller; 
use Illuminate\Foundation\Auth\ResetsPasswords; 

class ResetPasswordController extends Controller 
{ 
    /* 
    |-------------------------------------------------------------------------- 
    | Password Reset Controller 
    |-------------------------------------------------------------------------- 
    | 
    | This controller is responsible for handling password reset requests 
    | and uses a simple trait to include this behavior. You're free to 
    | explore this trait and override any methods you wish to tweak. 
    | 
    */ 

    use ResetsPasswords; 

    /** 
    * Where to redirect users after resetting their password. 
    * 
    * @var string 
    */ 
    protected $redirectTo = '/'; 

    /** 
    * Create a new controller instance. 
    * 
    * @return void 
    */ 
    public function __construct() 
    { 
     $this->middleware('guest'); 
    } 
} 

當我嘗試改變$重定向到變量登錄扔給我,頁面不能正常工作的錯誤.....我只是在混亂狀態,請helpme出

回答

0

你需要以下位於app/Http/Controllers/Auth.

更改重定向路徑到您的登錄頁面ResetPasswordController變化。

protected $redirectTo = '/login'; 

重寫resetPassword方法以防止用戶登錄。將其添加到控制器。

protected function resetPassword($user, $password) 
{ 
    $user->forceFill([ 
     'password' => bcrypt($password), 
     'remember_token' => Str::random(60), 
    ])->save(); 
} 

使用頂部的use Illuminate\Support\Str;

要在重定向上發送自定義響應,您可以在控制器中覆蓋sendResetResponse並添加任何自定義會話/閃存消息。默認情況下,laravel在成功的密碼重置時設置自己的響應。

protected function sendResetResponse($response) 
{ 
    return redirect($this->redirectPath()) 
         ->with('status', trans($response)); 
} 
相關問題