/** * Handle posting of the form for the forgot password. * * @return \Illuminate\Http\RedirectResponse */ public function remind() { $email = Input::get('email'); if ($user = Sentinel::findByCredentials(compact('email'))) { $reminder = Reminder::exists($user) ?: Reminder::create($user); $code = $reminder->code; $sent = Mail::send('sentinel.emails.reminder', compact('user', 'code'), function ($m) use($user) { $m->to($user->email)->subject('Reset your account password.'); }); } return Redirect::route('user.remember')->withSuccess('An email was sent with instructions on how to reset your password.'); }
/** * @return mixed */ public function updatepassword() { $rules = ['email' => 'required|email']; $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::back()->withInput()->withErrors($validator); } $email = Input::get('email'); $user = Sentinel::findByCredentials(compact('email')); if (!$user) { return Redirect::back()->withInput()->withErrors('No user with that email address belongs in our system.'); } $reminder = Reminder::exists($user) ?: Reminder::create($user); $code = $reminder->code; $sent = Mail::send('emails.reminder', compact('user', 'code'), function ($m) use($user) { $m->to($user->email)->subject('Reset your account password.'); }); if ($sent === 0) { return Redirect::to('register')->withErrors('Failed to send reset password email.'); } return Redirect::to('wait'); }
public function access_to_password_reset_page_while_logged_in(FunctionalTester $I) { $I->am('Unlogged user'); $I->wantTo('access to the password reset page while logged in'); $I->expectTo('be redirected to the home page'); /*************************************************************************************************************** * run test **************************************************************************************************************/ $user = \Sentinel::authenticate($this->_credentials); $reminder = Reminder::create($user); $I->amOnPage('/'); $I->amOnPage(config('app.url') . '/' . config('app.locale') . '/' . trans('routes.password.reset') . '?email=' . $user->email . '&token=' . $reminder->code); $I->amOnRoute('home'); }
public function testAddTable() { $e = null; try { $this->_conn->selectValues("SELECT * FROM reminders"); } catch (Exception $e) { } $this->assertInstanceOf('Horde_Db_Exception', $e); $m = new WeNeedReminders1(); $m->up(); $result = Reminder::create(array('content' => 'hello world', 'remind_at' => '2005-01-01 11:10:01')); $this->assertInstanceOf('Reminder', $result); $this->assertEquals('hello world', Reminder::find('first')->content); $m->down(); $e = null; try { $this->_conn->selectValues("SELECT * FROM reminders"); } catch (Exception $e) { } $this->assertInstanceOf('Horde_Db_Exception', $e); }
public function postForgot(Request $request) { $input = $request->all(); $credentials = ['email' => $request->email]; $rules = ['password' => 'required|email|exists:users,email']; $validator = Validator::make($input, $rules); if ($validator->fails()) { return back()->withInput()->withErrors($validator); } if ($user = Sentinel::findByCredentials($credentials)) { $reminder = Reminder::exists($user) ?: Reminder::create($user); $code = $reminder->code; $sent = Mail::send('sentinel.emails.reminder', compact('user', 'code'), function ($m) use($user) { $m->to($user->email)->subject('Reset your account password.'); }); return redirect()->route('wait'); } else { return back()->withInput()->with('fail', trans('validation.no_user_that_email')); } }
public function testMigratorGoingDownDueToVersionTarget() { $dir = dirname(dirname(dirname(dirname(__FILE__)))) . '/fixtures/migrations/'; Mad_Model_Migration_Migrator::up($dir, 1); Mad_Model_Migration_Migrator::down($dir, 0); $user = new User(); $columns = $user->columnNames(); $this->assertFalse(in_array('last_name', $columns)); $e = null; try { $this->_conn->selectValues("SELECT * FROM reminders"); } catch (Exception $e) { } $this->assertInstanceOf('Horde_Db_Exception', $e); Mad_Model_Migration_Migrator::up($dir); $user->resetColumnInformation(); $columns = $user->columnNames(); $this->assertTrue(in_array('last_name', $columns)); $result = Reminder::create(array('content' => 'hello world', 'remind_at' => '2005-01-01 02:22:23')); $reminder = Reminder::find('first'); $this->assertEquals('hello world', $reminder->content); }
/** * Begin the password reset process * * @param AccountForgotPassword $request * * @return $this */ public function InitForgotPassword(AccountForgotPassword $request) { try { $credentials = ['email' => \Input::get('email')]; $user = \Sentinel::getUserRepository()->findByCredentials($credentials); \Reminder::create($user); $reminder = \Reminder::exists($user); \Mail::queue('emails.account.resetpassword', ['username' => \Input::get('email'), 'user_id' => $user->getUserId(), 'reset_code' => $reminder['code'], 'reset_link' => env('URL') . '/auth/forgotpassword/set?' . http_build_query(array('ResetCode' => $reminder['code'], 'UserId' => $user->getUserId()))], function ($message) { $message->from('*****@*****.**', 'Modest Music | Account Services'); $message->to(\Input::get('email')); }); return redirect('auth/login')->withErrors(array('login' => 'We have sent you your reset link. Please check your Spam Email.')); } catch (\Exception $e) { return redirect('auth/forgotpassword')->withErrors(array('password_reset' => 'User Not found in our database!')); } }