diff --git a/server/api/index.js b/server/api/index.js index b389436..6148c6b 100644 --- a/server/api/index.js +++ b/server/api/index.js @@ -332,6 +332,9 @@ const API = { let auth = await models.OAuth2AuthorizedClient.query().where('user_id', user.id).andWhere('client_id', clientId) if (!auth.length) return false + await models.OAuth2AccessToken.query().delete().where('client_id', clientId).andWhere('user_id', user.id) + await models.OAuth2RefreshToken.query().delete().where('client_id', clientId).andWhere('user_id', user.id) + for (let i in auth) { await models.OAuth2AuthorizedClient.query().delete().where('id', auth[i].id) } diff --git a/server/api/oauth2/model.js b/server/api/oauth2/model.js index fa47bfc..ab51094 100644 --- a/server/api/oauth2/model.js +++ b/server/api/oauth2/model.js @@ -129,7 +129,6 @@ const OAuthDB = { await Models.OAuth2Code.query().delete().where('user_id', userId).andWhere('client_id', clientId) const obj = { code: code, user_id: userId, client_id: clientId, scope: scope, expires_at: expr, created_at: new Date() } - console.log(obj) await Models.OAuth2Code.query().insert(obj) diff --git a/src/script/main.js b/src/script/main.js index 8065132..bfa060d 100644 --- a/src/script/main.js +++ b/src/script/main.js @@ -55,8 +55,11 @@ $(document).ready(function () { if (!data.length) { return $('#clientlist').html('There is nothing to show at this moment.') } - var html = '' + + $('#clientlist').html('') + for (var i in data) { + var html = '' var client = data[i] html += '
' html += '
' @@ -75,13 +78,11 @@ $(document).ready(function () { html += '' + client.url + '' html += '
Authorized ' + new Date(client.created_at) + '
' html += '
' - } - $('#clientlist').html(html) + $('#clientlist').append(html) - for (let i in data) { - $('#client-' + data[i].id + ' #deleteclient').click(function (e) { - let clid = $(this).parent().data('client-id') + $('#client-' + client.id + ' #deleteclient').click(function (e) { + var clid = $(this).parent().data('client-id') if (clid != null) { removeAuthorization(clid) } diff --git a/views/user/settings.pug b/views/user/settings.pug index 7031bf3..8ea8ea8 100644 --- a/views/user/settings.pug +++ b/views/user/settings.pug @@ -61,7 +61,7 @@ block body i.fa.fa-fw.fa-envelope |Change Email Address .clients - h2 OAuth2 Authorized Clients + h2 OAuth2 Authorized Applications .cl#clientlist span.load i.fa.fa-spin.fa-spinner.fa-2x