Skip to content
Snippets Groups Projects
Commit cbf72acd authored by Artem Konenko's avatar Artem Konenko
Browse files

#159 Add description for API tokens

parent 30cbde97
Branches
Tags
No related merge requests found
......@@ -2277,6 +2277,7 @@ END//
DROP FUNCTION IF EXISTS CreateAuthToken//
CREATE FUNCTION CreateAuthToken(
pAccountID int(11),
pDescription varchar(60) CHARACTER SET utf8,
pRightMask int(11)
) RETURNS char(40) charset ascii
NO SQL
......@@ -2292,7 +2293,7 @@ BEGIN
SET vTries = vTries - 1;
SET vCreated = TRUE;
INSERT INTO auth_tokens(Token, AccountID, Mask) VALUES (vToken, pAccountID, pRightMask);
INSERT INTO auth_tokens(Token, AccountID, Description, Mask) VALUES (vToken, pAccountID, pDescription, pRightMask);
END; END WHILE;
RETURN IF(vCreated, vToken, NULL);
......
START TRANSACTION;
ALTER TABLE `auth_tokens`
ADD COLUMN `Description` varchar(60) CHARACTER SET utf8 NOT NULL DEFAULT '' AFTER `AccountID`;
COMMIT ;
......@@ -160,11 +160,12 @@ class Model_Account extends Model
* @param int $mask bit mask with access rights
* @return string token, if it was created. Empty string otherwise
*/
public static function createAuthToken($accountID, $mask = 0) {
$sql = 'SELECT `CreateAuthToken`(:user, :mask) AS `token`';
public static function createAuthToken($accountID, $mask = 0, $description = '') {
$sql = 'SELECT `CreateAuthToken`(:user, :description, :mask) AS `token`';
return DB::query(Database::SELECT, $sql)
->parameters([
':user' => (int) $accountID,
':description' => (string) $description,
':mask' => (int) $mask,
])->execute()->get('token');
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment