예제 #1
0
 /**
  * Handle the event.
  *
  * @param  UserWasRegistered  $event
  * @return void
  */
 public function handle(UserWasRegistered $event)
 {
     //
     $user = $event->getUser();
     $defaultRole = $this->role->where('is_default', '=', 1)->first();
     if ($defaultRole) {
         $user->attachRole($defaultRole);
     }
 }
예제 #2
0
 /**
  * Handle the event.
  *
  * @param  UserWasRegistered  $event
  * @return void
  */
 public function handle(UserWasRegistered $event)
 {
     //
     $user = $event->getUser();
     if ($user->getAccountConfirmation() == null) {
         $code = str_random(30);
         while ($this->confirmation->where('code', '=', $code) != null) {
             $code = str_random(30);
         }
         $confirmation = $this->confirmation->create(array('user_id' => $user->getId(), 'expires_at' => time() + 3600, 'code' => $code));
         $outgoingEmail = $this->settings->getByName('outgoing_email', '*****@*****.**');
         $siteName = $this->settings->getByName('sitename', 'A Fetch404 Site');
         $this->mail->send('core.emails.auth.confirm', ['user' => $user, 'confirmation' => $confirmation, 'siteName' => $siteName->value], function ($message) use($user, $outgoingEmail, $siteName) {
             $message->from($outgoingEmail->value)->to($user->getEmail())->subject('Confirm your ' . $siteName->value . ' account');
         });
     }
 }