Laravel - 覆盖resetPassword

时间:2016-08-10 06:54:03

标签: php laravel laravel-5.2

所以我的数据库中有两个用户名,名为Mahasiswas和Users,我想覆盖Mahasiswas表的resetPassword,因为每次重置Mahasiswas表的密码时,它都会自动登录到用户仪表板

我把它放在我的路线上:

Route::post('password/reset', 'MhsAuth\PasswordController@postMyReset');

这是我的密码控制器:

namespace App\Http\Controllers\MhsAuth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
class PasswordController extends Controller
{

  use ResetsPasswords;
  protected $redirectPath = '/';
  protected $getGuard = 'mahasiswa';

  public function __construct()
  {
     $this->middleware('mahasiswa');
  }

  public function postMyReset(Request $request)
  {
     return $this->resetMe($request);
  }

  public function resetMe(Request $request)
  {
     $this->validate($request, [
         'token' => 'required',
         'email' => 'required|email',
         'password' => 'required|confirmed|min:6',
     ]);

     $credentials = $request->only(
         'email', 'password', 'password_confirmation', 'token'
     );

     $broker = $this->getBroker();

     $response = Password::broker($broker)->reset($credentials, function ($user, $password) {
            $this->resetMyPassword($user, $password);
     });

        switch ($response) {
                case Password::PASSWORD_RESET:
                    return $this->getResetSuccessResponse($response);

                default:
                    return $this->getResetFailureResponse($request, $response);
        }
    }

    protected function resetMyPassword($user, $password)
    {
        $user->password = bcrypt($password);
        $user->save();
        //Auth::guard($this->getGuard())->login($user);
    }

}

问题是重置了Mahasiswas表的密码后,它会自动登录到用户仪表板,它应该在Mahasiswas Dashboard中,但我只是想禁用自动登录,而我的密码控制器不起作用我想要的。感谢

0 个答案:

没有答案