From 8bb71f2e332726c207318e44b95e784f9740dc40 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 5 May 2020 09:44:53 +0200 Subject: [PATCH] Add auth plugin info in users list --- .../users/user-list/user-list.component.html | 7 +++++++ client/src/app/shared/users/user.model.ts | 4 ++++ server/models/account/user.ts | 4 +++- server/tests/plugins/id-and-pass-auth.ts | 16 +++++++++++++++- shared/models/users/user.model.ts | 2 ++ 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/client/src/app/+admin/users/user-list/user-list.component.html b/client/src/app/+admin/users/user-list/user-list.component.html index 8b71dae79..d9612cf9c 100644 --- a/client/src/app/+admin/users/user-list/user-list.component.html +++ b/client/src/app/+admin/users/user-list/user-list.component.html @@ -46,6 +46,7 @@ Email Video quota Role + Auth plugin Created @@ -97,7 +98,13 @@ {{ user.videoQuotaUsed }} / {{ user.videoQuota }} {{ user.roleLabel }} + + + {{ user.pluginAuth }} + + {{ user.createdAt }} + diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts index 76c57d2fb..3f6743bef 100644 --- a/client/src/app/shared/users/user.model.ts +++ b/client/src/app/shared/users/user.model.ts @@ -69,6 +69,8 @@ export class User implements UserServerModel { noInstanceConfigWarningModal: boolean noWelcomeModal: boolean + pluginAuth: string | null + createdAt: Date constructor (hash: Partial) { @@ -112,6 +114,8 @@ export class User implements UserServerModel { this.createdAt = hash.createdAt + this.pluginAuth = hash.pluginAuth + if (hash.account !== undefined) { this.account = new Account(hash.account) } diff --git a/server/models/account/user.ts b/server/models/account/user.ts index 1bff955df..260c1b28e 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts @@ -806,7 +806,9 @@ export class UserModel extends Model { videoChannels: [], - createdAt: this.createdAt + createdAt: this.createdAt, + + pluginAuth: this.pluginAuth } if (parameters.withAdminFlags) { diff --git a/server/tests/plugins/id-and-pass-auth.ts b/server/tests/plugins/id-and-pass-auth.ts index 97df4c1fd..cbba638c2 100644 --- a/server/tests/plugins/id-and-pass-auth.ts +++ b/server/tests/plugins/id-and-pass-auth.ts @@ -12,7 +12,7 @@ import { updateMyUser, userLogin, wait, - login, refreshToken, getConfig, updatePluginSettings + login, refreshToken, getConfig, updatePluginSettings, getUsersList } from '../../../shared/extra-utils' import { User, UserRole, ServerConfig } from '@shared/models' import { expect } from 'chai' @@ -225,6 +225,20 @@ describe('Test id and pass auth plugins', function () { expect(crashAuth).to.not.exist }) + it('Should display plugin auth information in users list', async function () { + const res = await getUsersList(server.url, server.accessToken) + + const users: User[] = res.body.data + + const root = users.find(u => u.username === 'root') + const crash = users.find(u => u.username === 'crash') + const laguna = users.find(u => u.username === 'laguna') + + expect(root.pluginAuth).to.be.null + expect(crash.pluginAuth).to.equal('peertube-plugin-test-id-pass-auth-one') + expect(laguna.pluginAuth).to.equal('peertube-plugin-test-id-pass-auth-two') + }) + after(async function () { await cleanupTests([ server ]) }) diff --git a/shared/models/users/user.model.ts b/shared/models/users/user.model.ts index a9c9bce30..42be04289 100644 --- a/shared/models/users/user.model.ts +++ b/shared/models/users/user.model.ts @@ -50,6 +50,8 @@ export interface User { noWelcomeModal: boolean createdAt: Date + + pluginAuth: string | null } export interface MyUserSpecialPlaylist { -- 2.25.1