public function login() { $this->helpers[] = 'JsValidate.Validation'; $this->AuthUser; $this->set('title', __t('Login')); if (!empty($this->data['AuthUser']['username'])) { if (SlAuth::login($this->data['AuthUser']['username'], $this->data['AuthUser']['password'], array('remember' => $this->data['AuthUser']['remember']))) { $key = empty($this->params['admin']) ? 'Auth.url.afterLogin' : 'Auth.url.afterAdminLogin'; $url = SlConfigure::read2($key); SlSession::delete($key); $this->redirect($url); } else { $this->Session->setFlash(__t('Login error. Check username and password')); } } }
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')); } } }