Esempio n. 1
0
 public function doLookup()
 {
     $req = $this->app->request;
     $user = new \Models\User();
     $email = $req->post('email');
     if ('' == $email) {
         $this->app->flashNow('lookupError', true);
         $this->app->render('forgot.twig');
         return;
     }
     if ('findUsername' == $req->post('lookupOptions')) {
         $username = $user->getUsername($email);
         if ('' == $username) {
             $this->app->flashNow('lookupError', true);
             $this->app->render('forgot.twig');
             return;
         }
         $this->app->flashNow('foundUsername', $username);
         $this->app->flashNow('email', $email);
         $this->app->flash('username', $username);
         $this->app->render('forgot.twig');
     } else {
         if ('resetPassword' == $req->post('lookupOptions')) {
             list($success, $newPass) = $user->resetPassword($email);
             if (!$success) {
                 $this->app->flashNow('lookupError', true);
                 $this->app->render('forgot.twig');
                 return;
             }
             $this->app->flashNow('email', $email);
             $this->app->flashNow('resetPassword', true);
             // TODO: Send email with new password.
             $this->app->render('forgot.twig');
         } else {
             $this->app->notFound();
         }
     }
 }