Ejemplo n.º 1
0
 public function resetPost(Requests\Auth\ResetPassword $request, AppMailer $mailer)
 {
     $email = $request->input('email');
     $user = User::where('email', $email)->first();
     if (!$user) {
         session()->flash('error', 'No account found with that email!');
         return redirect()->back()->withInput();
     }
     if (!$user->verified()) {
         session()->flash('error', 'You must confirm your email before resetting your password!');
         return redirect()->route('home');
     }
     if (!$user->passwordReset) {
         $reset = $user->passwordReset()->create(['token' => str_random(30), 'created_at' => Carbon::now()]);
         $mailer->sendPasswordResetTo($reset->user);
         session()->flash('success', 'Password reset email has been sent!');
         return redirect()->route('home');
     }
     if ($user->passwordReset->created_at > Carbon::now()->subMinutes(15)) {
         session()->flash('error', 'You must wait ' . $user->passwordReset->created_at->addMinutes(15)->diffForHumans() . ' before requesting a new reset email!');
         return redirect()->back()->withInput();
     }
     $user->passwordReset()->update(['token' => str_random(30), 'created_at' => Carbon::now()]);
     $mailer->sendPasswordResetTo($user);
     session()->flash('success', 'Password reset email has been resent!');
     return redirect()->route('home');
 }
Ejemplo n.º 2
0
 public function activate(Request $request, AppMailer $mailer)
 {
     $user = User::find($request->input('id'));
     $user->verified = 1;
     $user->save();
     $user->emailVerification()->delete();
     $mailer->sendManualActivationEmailTo($user);
     session()->flash('success', 'User <strong>' . $user->username . '</strong> successfully activated!');
     return redirect()->route('admin.users');
 }
Ejemplo n.º 3
0
 public function resendPost(Requests\Auth\ResendEmailConfirmation $request, AppMailer $mailer)
 {
     $email = $request->email;
     $user = User::where('email', $email)->first();
     if (!$user) {
         session()->flash('error', 'No account found with that email!');
         return redirect()->back()->withInput();
     }
     if ($user->verified()) {
         session()->flash('error', 'Your account is already confirmed! No need for confirmation.');
         return redirect()->route('login');
     }
     if ($user->emailVerification->created_at > Carbon::now()->subSeconds(2)) {
         session()->flash('error', 'You must wait ' . $user->emailVerification->created_at->addMinutes(15)->diffForHumans() . ' before requesting a new confirmation!');
         return back()->withInput();
     }
     $user->emailVerification->delete();
     $confirmation = $user->emailVerification()->create(['token' => str_random(30), 'created_at' => Carbon::now()]);
     $mailer->sendEmailConfirmationTo($confirmation->user);
     session()->flash('success', 'Email confirmation has been resent!<br>May take up to 15 minutes. Be sure to check Spam/Junk folders!');
     return redirect()->route('home');
 }