public function login($hash = false) { $this->controller->loadModel($this->config['model']); $data = $this->controller->request->data[$this->config['model']]; if ($hash) { $password = Security::hash($data['password']); } else { $password = $data['password']; } $user = $this->controller->{$this->config['model']}->find('first')->select()->where([$this->config['fields']['username'] => $data['username'], $this->config['fields']['password'] => $password])->build(); if (!empty($user->{$this->config['model']})) { $this->setUser($user->{$this->config['model']}); return true; } return false; }
public static function generateKey() { return Security::hash(String::uuid()); }