Ejemplo n.º 1
0
 public function changeEmail(EmailChange $request)
 {
     $newEmail = $request->input('new_email');
     $this->auth->user()->update(['email' => $newEmail]);
     $this->tokens->delete($newEmail);
     return api_response(200);
 }
Ejemplo n.º 2
0
 /**
  * Confirm email change
  *
  * @return Redirect
  */
 public function getConfirmEmail()
 {
     $confirmValidator = \Validator::make(\Input::all(), array('token' => 'required|min:1'));
     if ($confirmValidator->fails()) {
         return \Redirect::route('user.index')->with('flash_error', \Lang::get('gekko::user.confirm_email_no_token'))->withInput();
     }
     $emailChangeData = \EmailChange::where('token', '=', \Input::get('token'))->first();
     if (is_null($emailChangeData)) {
         return \Redirect::route('user.index')->with('flash_error', \Lang::get('gekko::user.confirm_email_token_mismatch'))->withInput();
     }
     $expiry_minutes = \Config::get('auth.reminder.expire', 60);
     $expiry_time = $emailChangeData->updated_at->timestamp + $expiry_minutes * 60;
     if ($expiry_time < time()) {
         return \Redirect::route('user.index')->with('flash_error', \Lang::get('gekko::user.confirm_email_token_expired'))->withInput();
     }
     $new_email = $emailChangeData->new_email;
     $emailChangeData->user->email = $new_email;
     $emailChangeData->user->save();
     $emailChangeData->token = "";
     $emailChangeData->new_email = "";
     $emailChangeData->save();
     return \Redirect::route('user.index')->with('flash_notice', \Lang::get('gekko::user.confirm_email_success', array('email' => $new_email)))->withInput();
 }
Ejemplo n.º 3
0
 /**
  * Gets the pending email changes for a user
  *
  * @return EmailChange
  */
 public function emailChanges()
 {
     return EmailChange::firstOrCreate(['user_id' => $this->getKey()]);
 }