Exemplo n.º 1
0
 /**
  * POST: /admin/edit-user
  */
 public function editUserPost()
 {
     if (!Authentication::hasRoles(array('admin'))) {
         parent::redirectToUrlFromAction('admin', 'no-access');
     }
     $roleDAO = new RoleDAO();
     $roles = $roleDAO->getRoles();
     $model = new AdminEditUserModel('', true, $roles);
     $model->title = Language::$EDIT_USER[Config::$LANGUAGE] . ' "' . $model->email . '"';
     (new UserDAO())->changeLockout($model->id, $model->lockoutEnabled, $model->lockoutEndDate);
     $roleDAO->removeRolesOfUser($model->id);
     foreach ($model->roleNames as $roleName) {
         $roleDAO->addedRoleToUser($roleName, $model->id);
     }
     parent::redirectToUrlFromAction('admin', 'users');
 }
Exemplo n.º 2
0
 /**
  * POST: /account/register
  */
 public function registerPost()
 {
     $model = new AccountRegisterModel(Language::$REGISTER[Config::$LANGUAGE], true);
     if ($model->validation) {
         $userDAO = new UserDAO();
         $hasUser = $userDAO->hasUser($model->email);
         if (!$hasUser) {
             $uniqueId = $userDAO->createUser($model->email, $model->password);
             $userEntity = $userDAO->getUserWithRolesByUniqueId($uniqueId);
             $roleDAO = new RoleDAO();
             if ($userDAO->countUsers() == 0) {
                 $roleDAO->addedRoleToUser('admin', $userEntity->id);
             }
             $roleDAO->addedRoleToUser('user', $userEntity->id);
             (new BrowsingDAO())->addedBrowsingToUser($userEntity->id, Browsing::getBrowsingId());
             if (Config::$SMTP) {
                 //Send email for confirm email address
                 (new Email())->send($model->email, Language::$CONFIRM_EMAIL[Config::$LANGUAGE], Language::$CONFIRM_EMAIL[Config::$LANGUAGE] . ' http://' . $_SERVER['SERVER_NAME'] . '/account/confirm-email/' . $uniqueId);
             }
             Authentication::signIn($uniqueId);
             parent::redirectToUrlFromArray(explode('/', $model->url));
         }
         $model->emailValidation = Language::$DUPLICATE_EMAIL[Config::$LANGUAGE];
         $model->validation = false;
     }
     parent::view(new Register(), $model);
 }