/** * Handles POST requests to the password reset form * * @access public * @return \Illuminate\Support\Facades\Redirect */ public function postForgot() { // Define validation rules $validator = Validator::make(Input::all(), array('username' => 'required|exists:users,username,type,db')); // Run the validator if ($validator->passes()) { // Generate a random password $password = str_random(8); // Now we update the password in the database $user = User::where('username', Input::get('username'))->where('type', 'db')->first(); $user->password = PHPass::make()->create($password, $user->salt); $user->save(); // Build the email template $data = array_merge(View::defaults(), array('name' => $user->dispname ?: $user->username, 'password' => $password)); // Send the notification mail Mail::queue('templates/email/forgot', $data, function ($message) use($user) { $message->to($user->email)->subject(Lang::get('mail.forgot_subject')); }); // All done! Session::flash('messages.success', Lang::get('user.reset_done')); return Redirect::to('user/login'); } else { Session::flash('messages.error', $validator->messages()->all('<p>:message</p>')); return Redirect::to('user/forgot')->withInput(); } }
/** * This abstraction over the base method injects the skin name * and default view data. * * @param string $view * @param array $data * @param int $status * @param array $headers * @return \Illuminate\View\View */ public static function view($view, $data = array(), $status = 200, array $headers = array()) { $data = array_merge(View::defaults(), $data); return parent::view(View::inject($view), $data, $status, $headers); }