/** * To login account. * * @param string $username User name. * @param string $password User password. * * @return response array(session, user array). */ public function login($username, $password) { $model = \Model\User::Instance(); if ($error = $model->validate(array('username' => $username, 'password' => $password)) != "") { $this->response['error'] = $error; return $this->response; } $user = $model->find(array('username' => $username)); if (!$user) { $this->response['error'] = "Sorry, no this user"; return $this->response; } if ($user['password'] != $password) { $this->response['error'] = "Sorry, username or password is wrong."; return $this->response; } $response['user'] = $user; $response['session'] = 'testtestse'; // 这里会修改, 以后数据层不再负责session 会话. $this->response['data'] = $response; return $this->response; }
/** * 获取用户列表.. * * @param array $userId 用户Id. * * @return array */ public function getUsers($userId) { $model = \Model\User::Instance(); $user = $model->getAlbumWithCoverByIds($userId); return $user; }