/** * Logging in and out */ public function login($email, $password) { $user = User::findOne(array('email' => $email)); if (!$user) { return array('error' => 404, 'message' => 'No such user'); } if ($user->password !== $this->password($password)) { return array('error' => 401, 'message' => 'Invalid Password'); } $this->login_apply((string) $user->id, $user->token); return array('message' => 'Login Success'); }
/** * Create CLI User (Requires API Key Access) */ public function assertCliUser() { $this->user = User::findOne(array('email' => '*****@*****.**')); if (!$this->user) { $this->user = User::create(array('email' => '*****@*****.**')); $this->user->createApiKey(); } $apikeys = array_keys($this->user->apikeys); $this->apikey = isset($apikeys[0]) ? $apikeys[0] : false; if (!$this->apikey) { $this->user->createApiKey(); $this->assertCliUser(); } }