/**
  * Handle the event.
  *
  * @param  SubscriptionCreated  $event
  * @return void
  */
 public function handle(SubscriptionCreated $event)
 {
     $user = $event->user;
     $token = substr(md5(rand()), 0, 17);
     while (ConfirmationToken::where('token', $token)->first() != null) {
         $token = substr(md5(rand()), 0, 17);
     }
     $confirmationToken = ConfirmationToken::create(['user_id' => $user->id, 'token' => $token]);
     $confirmationToken->save();
     event(new ConfirmationTokenCreated($confirmationToken));
 }
Exemplo n.º 2
0
 /**
  * Handle the event.
  *
  * @param  ResendConfirmationEmailEvent  $event
  * @return void
  */
 public function handle(ResendConfirmationEmailEvent $event)
 {
     $user = User::where('email', $event->email)->first();
     if ($user) {
         $confirmationToken = $user->confirmationToken;
         $token = substr(md5(rand()), 0, 17);
         while (ConfirmationToken::where('token', $token)->first() != null) {
             $token = substr(md5(rand()), 0, 17);
         }
         $confirmationToken->update(['token' => $token]);
         event(new ConfirmationTokenCreated($confirmationToken));
     }
 }
Exemplo n.º 3
0
 public function confirmSubscription(Request $request)
 {
     $this->validate($request, ['token' => 'required|size:17|exists:confirmation_tokens,token'], $this->confirmSubscriptionMessages());
     /** @var ConfirmationToken $token */
     $token = ConfirmationToken::where('token', $request->input('token'))->first();
     /** @var User $user */
     $user = $token->user;
     if (Carbon::now()->subWeeks(2) < $token->updated_at) {
         $user->setAsConfirmedUser();
         return view('subscription_confirmed', ['email' => $token->user->email, 'date_next_email' => ChallengeHelper::getNextEmailApproximateDate($token->user->frequency)]);
     } else {
         return view('subscription_token_expired', ['email' => $token->user->email]);
     }
 }