示例#1
0
 /**
  * Get the user's account confirmation object.
  *
  * @return AccountConfirmation
  */
 public function getAccountConfirmation()
 {
     $confirmation = AccountConfirmation::where('user_id', '=', $this->id)->first();
     if ($confirmation == null) {
         return null;
     }
     if ($this->isConfirmed()) {
         return null;
     }
     return $confirmation;
 }
示例#2
0
 /**
  * Update an account's settings
  *
  * @param AccountSettingsUpdateRequest $request
  */
 public function updateSettings(AccountSettingsUpdateRequest $request)
 {
     $username = $request->input('name');
     $email = $request->input('email');
     $password = $request->input('password');
     $user = $request->user();
     // Set $user to the request's current user.
     $oldName = $user->name;
     if (!$user) {
         return redirect()->to('/');
     }
     if ($username != $user->name && $username != '') {
         $user->update(array('name' => $username));
         try {
             $user->nameChanges()->create(array('user_id' => $user->id, 'old_name' => $oldName, 'new_name' => $username));
         } catch (\PDOException $ex) {
         }
     }
     if ($email != $user->email && $email != '') {
         $user->update(array('email' => $email));
         $confirmation = AccountConfirmation::create(array('user_id' => $user->id, 'expires_at' => time() + 3600, 'code' => str_random(30)));
         $outgoingEmail = Setting::where('name', '=', 'outgoing_email')->first();
         $siteName = Setting::where('name', '=', 'sitename')->first();
         $this->mail->send('core.emails.auth.reconfirm', ['user' => $user, 'confirmation' => $confirmation, 'siteName' => $siteName], function ($message) use($email, $outgoingEmail, $siteName) {
             $message->from($outgoingEmail->value)->to($email)->subject('Please re-confirm your email');
         });
     }
     return redirect()->to('/account/settings');
 }