Пример #1
0
 public function resetFirstTimePassword(Request $request)
 {
     $this->validate($request, ['password' => 'confirmed|min:6|same:password_confirmation']);
     $token = $request->input('token');
     $email = $request->input('email');
     $activator = AccountActivation::where('code', $token)->valid()->for($email)->latest();
     if (!isset($activator)) {
         return redirect('/');
     }
     $user = User::where('email', $email)->first();
     $user->password = bcrypt($request->input('password'));
     $user->status = 'active';
     $user->save();
     $activator->deactivate();
     if (Auth::attempt(['email' => $user->email, 'password' => $request->input('password')])) {
         return redirect(url('/home'));
     } else {
         return redirect(url('/auth/login'));
     }
 }
Пример #2
0
 public function verifyToken($token)
 {
     $activator = AccountActivation::where('code', $token)->valid()->first();
     if (isset($activator)) {
         $dest = $activator->delivered_to;
         if ($activator->destination == 'email') {
             $user = User::where('email', $dest)->first();
         } else {
             $user = User::where('phone', $dest)->first();
         }
         if (isset($user)) {
             //$activator->deactivate();
             return view('auth.passwords.firstTimePassword', compact('dest', 'token'));
         } else {
             if ($activator->destination == 'email') {
                 return redirect(url('register'))->withInput(['email' => $dest]);
             } else {
                 return redirect(url('register'))->withInput(['phone' => $dest]);
             }
         }
     } else {
         return redirect(url('/'));
     }
 }