Ejemplo n.º 1
0
 public function admin_edit()
 {
     $this->helpers[] = 'JsValidate.Validation';
     if ($this->data) {
         if ($this->_passwordMatch()) {
             $data = $this->data;
             if ($data['AuthUser']['password']) {
                 $data['AuthUser']['password'] = SlAuth::password($data['AuthUser']['password']);
             } else {
                 unset($data['AuthUser']['password']);
             }
             if ($this->AuthUser->saveAll($data)) {
                 $this->redirect(array('action' => 'index'));
             }
         }
     } elseif ($this->id) {
         $this->data = $this->AuthUser->read(null, $this->id);
         if (empty($this->data)) {
             $this->cakeError();
         }
         unset($this->data['AuthUser']['password']);
     }
     $this->_admin_edit();
     $this->set('authGroups', $this->AuthUser->AuthGroup->find('list'));
 }
Ejemplo n.º 2
0
 public function auth()
 {
     $this->helpers[] = 'JsValidate.Validation';
     $this->set('title', __t('StarLight installation: Administrator profile'));
     if (!SlExtensions::loaded('Auth')) {
         $this->Session->setFlash(__t('Auth extension is disabled. All security settings will be ignored.'));
         $this->redirect(array('action' => 'done'));
     }
     //        $this->loadModel('Auth.AuthUser');
     $user = $this->AuthUser->read(null, 1);
     if ($user) {
         $this->Session->setFlash(__t('Administrator profile step skipped. A root user (<b>{$username}</b>) is already registered.', array('username' => $user['AuthUser']['username'])), array('class' => 'message'));
         $this->redirect(array('action' => 'done'));
     }
     if ($this->data) {
         $success = $this->data['AuthUser']['password'] == $this->data['AuthUser']['confirm_password'];
         if (!$success) {
             $this->AuthUser->invalidate('password', __t('Passwords do not match'));
             return;
         }
         $password = $this->data['AuthUser']['password'];
         $this->data['AuthGroup']['AuthGroup'] = array(1, 2);
         $this->data['AuthUser']['password'] = SlAuth::password($this->data['AuthUser']['password']);
         $this->data['AuthUser']['active'] = true;
         // force loading of associated model
         $this->AuthUser->AuthGroup;
         if ($this->AuthUser->saveAll($this->data)) {
             SlAuth::login($this->data['AuthUser']['username'], $password);
             $this->redirect(array('action' => 'done'));
         }
     }
 }