Esempio n. 1
0
 /**
  * POST: /admin/users
  */
 public function usersPost()
 {
     if (!Authentication::hasRoles(array('admin'))) {
         parent::redirectToUrlFromAction('admin', 'no-access');
     }
     $userDAO = new UserDAO();
     $roles = (new RoleDAO())->getRoles();
     $model = new AdminUsersModel(Language::$USERS[Config::$LANGUAGE], true, $roles);
     $model->usersWithRoles = $userDAO->getUsersWithRoles($model->page, $model->size, $model->sort, $model->email, $model->emailConfirmed, $model->createdDateFrom, $model->createdDateTo, $model->lastLoginDateFrom, $model->lastLoginDateTo, $model->roleNames);
     $model->total = $userDAO->countUsersWithRoles($model->email, $model->emailConfirmed, $model->createdDateFrom, $model->createdDateTo, $model->lastLoginDateFrom, $model->lastLoginDateTo, $model->roleNames);
     $model->query = "/{$model->email}/{$model->emailConfirmed}/" . ($model->createdDateFrom != null ? $model->createdDateFrom->format('Y-m-d') : '') . "/" . ($model->createdDateTo != null ? $model->createdDateTo->format('Y-m-d') : '') . "/" . ($model->lastLoginDateFrom != null ? $model->lastLoginDateFrom->format('Y-m-d') : '') . "/" . ($model->lastLoginDateTo != null ? $model->lastLoginDateTo->format('Y-m-d') : '') . "/" . ($model->roleNames != null ? implode(',', $model->roleNames) : '');
     parent::view(new Users(), $model);
 }
Esempio n. 2
0
 /**
  * POST: /manage/delete
  */
 public function deletePost()
 {
     $model = new ManageDeleteModel(Language::$DELETE_ACCOUNT[Config::$LANGUAGE], true);
     if ($model->validation) {
         $userDAO = new UserDAO();
         $errorMessage = $userDAO->passwordVerify($model->authenticatedUserEntity->id, $model->password, $model->authenticatedUserEntity->passwordHash, $model->authenticatedUserEntity->lockoutEnabled, $model->authenticatedUserEntity->lockoutEndDate, $model->authenticatedUserEntity->accessFailedCount);
         if ($errorMessage == '') {
             $userDAO->delete($model->authenticatedUserEntity->id);
             Authentication::signOut();
             parent::redirectToUrlFromAction('main', 'index');
         }
         $model->passwordValidation = Language::$INVALID_PASSWORD[Config::$LANGUAGE] . " {$errorMessage}";
         $model->validation = false;
     }
     parent::view(new Delete(), $model);
 }
Esempio n. 3
0
 /**
  * POST: /account/forgot-password
  */
 public function forgotPasswordPost()
 {
     $model = new AccountForgotPasswordModel(Language::$FORGOT_PASSWORD[Config::$LANGUAGE], true);
     if ($model->validation) {
         $userDAO = new UserDAO();
         $hasUser = $userDAO->hasUser($model->email);
         if ($hasUser) {
             $forgotPassword = $userDAO->forgotPassword($model->email);
             //Send email for reset password
             (new Email())->send($model->email, Language::$RESET_YOUR_PASSWORD[Config::$LANGUAGE], Language::$RESET_YOUR_PASSWORD[Config::$LANGUAGE] . ' http://' . $_SERVER['SERVER_NAME'] . '/account/reset-password/' . $forgotPassword);
             parent::redirectToUrlFromAction('account', 'forgot-password-confirmation');
         }
         $model->emailValidation = Language::$USER_WITH_EMAIL_NOT_EXIST[Config::$LANGUAGE];
         $model->validation = false;
     }
     parent::view(new ForgotPassword(), $model);
 }