Add auth_more field for more authentication data needed

master
Bofh 2021-11-27 02:45:18 +01:00
parent 418d4f3371
commit adff3cc36f
2 changed files with 3 additions and 2 deletions

View File

@ -3,5 +3,6 @@ CREATE TABLE IF NOT EXISTS oauth_tokens (
id_user INTEGER NOT NULL,
cookie VARCHAR(64) UNIQUE NOT NULL,
access_token VARCHAR(128) NOT NULL,
auth_more TEXT NOT NULL,
created_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);

View File

@ -53,9 +53,9 @@ else
# create cookie and add access_token
$cookie = hash_hmac('sha256', $auth->access_token.$id_user, 'session');
$sm = $db->prepare('INSERT INTO oauth_tokens (id_user, cookie, access_token) VALUES (?, ?, ?)');
$sm = $db->prepare('INSERT INTO oauth_tokens (id_user, cookie, access_token, auth_more) VALUES (?, ?, ?, ?)');
try {
$sm->execute([$id_user, $cookie, $auth->access_token]);
$sm->execute([$id_user, $cookie, $auth->access_token, json_encode($payload->result)]);
} catch (PDOException $e) {
# TODO: log error
}