From 33944ae599a6dc7711526399afd11bc0235d5e45 Mon Sep 17 00:00:00 2001 From: Evert Date: Sat, 26 Aug 2017 13:02:17 +0300 Subject: [PATCH] little changes --- server/api/index.js | 3 +++ server/api/oauth2/model.js | 1 - src/script/main.js | 13 +++++++------ views/user/settings.pug | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) 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