$user->send_reset_email(); $app->flash('messages', ['info' => ['Email send with password reset instructions']]); $app->redirect('/'); }); //password_resets#edit $app->get("/password_resets/:reset_digest/edit/:email", SessionsHelper::not_logged_in_user($app), function ($reset_digest, $email) use($app) { $user = User::where('email', '=', StringHelper::base64_url_decode($email))->first(); PasswordResetsHelper::valid_user($app, $user, $reset_digest); PasswordResetsHelper::check_expiration($app, $user); SessionsHelper::is_activated($app, $user); $app->render('password_resets/edit.php', ['reset_digest' => $reset_digest, 'email' => $email]); }); //password_resets#update $app->post("/password_resets/:reset_digest", SessionsHelper::not_logged_in_user($app), function ($reset_digest) use($app, $validator) { $params = $app->request()->post(); $user = User::where('email', '=', StringHelper::base64_url_decode($params['email']))->first(); PasswordResetsHelper::valid_user($app, $user, $reset_digest); PasswordResetsHelper::check_expiration($app, $user); SessionsHelper::is_activated($app, $user); $validation = $validator->make($params, array_merge(User::$password_rules)); //creating array of errors $message_password_confirmation = array(); if ($params['password'] != $params['password_confirmation']) { $message_password_confirmation = ['Password confirmation doesn\'t match']; } $messages_validation = $validation->messages()->all(); $messages_all = array_merge($message_password_confirmation, $messages_validation); //if there is any validation errors if (!empty($messages_all)) { $app->flash('messages', ['danger' => $messages_all]); $app->redirect('/password_resets/' . $reset_digest . '/edit/' . $params['email']);
public function password_verify($password) { return password_verify($password, StringHelper::base64_url_decode($this->password_digest)); }