24 $this->db = $service->getDb();
36 if (!isset($options[
"login"]) || !is_string($options[
"login"])) {
37 throw new \Exception(
"Missing required parameter login", self::ERR_INVALID_ARGUMENT);
39 if (!isset($options[
"password"]) || !is_string($options[
"password"])) {
40 throw new \Exception(
"Missing required parameter password", self::ERR_INVALID_ARGUMENT);
43 if (!preg_match(
"#^[0-9a-zA-Z-]{1,32}$#", $options[
"login"])) {
44 throw new \Exception(
"Invalid login", self::ERR_INVALID_LOGIN);
47 $stmt =
$db->query(
"SELECT m.enabled,m.uid,m.login,m.su FROM membres m WHERE m.login=? AND m.password=?;", array($options[
"login"], $options[
"password"]), PDO::FETCH_CLASS);
50 return new Alternc_Api_Response(array(
"code" => ERR_INVALID_AUTH,
"message" =>
"Invalid login or password"));
52 return new Alternc_Api_Response(array(
"code" => ERR_DISABLED_ACCOUNT,
"message" =>
"Account is disabled"));
55 array(
"uid" => $me->uid,
"isAdmin" => ($me->su != 0)), $this->db
64 return array(
"fields" => array(
"login" =>
"AlternC user account",
"password" =>
"AlternC's user password stored in membres table."),
65 "description" =>
"Authenticate against an AlternC user and password, the same as for the control panel"
static tokenGenerate($options, $db)
Create a new token in the DB for the associated user/admin.
Authentication API used by server to authenticate a user using his alternc login and password...
instructions()
instructions on how to use this Auth class
const ERR_INVALID_ARGUMENT
auth($options)
Authenticate a user.
Authentication API used by server to authenticate a user using a specific method. ...
__construct($service)
Constructor of the Login Api Auth.
Service API used by server to export API methods this class can be used to implement an API service /...
Standard Response object for the AlternC API.