From adff3cc36f11532e370e2720d68eec95bc39776a Mon Sep 17 00:00:00 2001 From: Bastard Operator Date: Sat, 27 Nov 2021 02:45:18 +0100 Subject: [PATCH] Add auth_more field for more authentication data needed --- migrations/00004-create-oauth_tokens-table.sql | 1 + src/action/oauth/mastodon.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/migrations/00004-create-oauth_tokens-table.sql b/migrations/00004-create-oauth_tokens-table.sql index d163ca8..c865a72 100644 --- a/migrations/00004-create-oauth_tokens-table.sql +++ b/migrations/00004-create-oauth_tokens-table.sql @@ -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 ); diff --git a/src/action/oauth/mastodon.php b/src/action/oauth/mastodon.php index bf13134..ca20c33 100644 --- a/src/action/oauth/mastodon.php +++ b/src/action/oauth/mastodon.php @@ -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 }