douqie6454 2016-08-10 06:54
浏览 105

Laravel - 覆盖resetPassword

So I have two tables of users in my database with the name Mahasiswas and Users, and I want to override the resetPassword for Mahasiswas table, because every time I reset the password for the Mahasiswas table, it automatically logged into the Users dashboard.

I put this in my route :

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

And this is my passwordController :

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);
    }

}

The problem is after reset the password for Mahasiswas table, it's perform auto login to Users Dashboard, it should be in Mahasiswas Dashboard, but I just want to disable the autologin and my passwordController doesn't work as I wanted. Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 iOS开发关于快捷指令截屏后如何将截屏(或从截屏中提取出的文本)回传给本应用并打开指定页面
    • ¥15 unity连接Sqlserver
    • ¥15 图中这种约束条件lingo该怎么表示出来
    • ¥15 VSCode里的Prettier如何实现等式赋值后的对齐效果?
    • ¥15 流式socket文件传输答疑
    • ¥20 keepalive配置业务服务双机单活的方法。业务服务一定是要双机单活的方式
    • ¥50 关于多次提交POST数据后,无法获取到POST数据参数的问题
    • ¥15 win10,这种情况怎么办
    • ¥15 如何在配置使用Prettier的VSCode中通过Better Align插件来对齐等式?(相关搜索:格式化)
    • ¥100 在连接内网VPN时,如何同时保持互联网连接