Add auth plugin info in users list
authorChocobozzz <me@florianbigard.com>
Tue, 5 May 2020 07:44:53 +0000 (09:44 +0200)
committerChocobozzz <me@florianbigard.com>
Tue, 5 May 2020 11:54:30 +0000 (13:54 +0200)
client/src/app/+admin/users/user-list/user-list.component.html
client/src/app/shared/users/user.model.ts
server/models/account/user.ts
server/tests/plugins/id-and-pass-auth.ts
shared/models/users/user.model.ts

index 8b71dae79d4fe9fbbdb5214cfba7caabeed3f507..d9612cf9c724bc383fe5754e2ba89169f1ee5a05 100644 (file)
@@ -46,6 +46,7 @@
       <th i18n>Email</th>
       <th i18n pSortableColumn="videoQuotaUsed">Video quota <p-sortIcon field="videoQuotaUsed"></p-sortIcon></th>
       <th i18n>Role</th>
+      <th i18n>Auth plugin</th>
       <th i18n pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th>
       <th style="width: 50px;"></th>
     </tr>
 
       <td>{{ user.videoQuotaUsed }} / {{ user.videoQuota }}</td>
       <td>{{ user.roleLabel }}</td>
+
+      <td>
+        <ng-container *ngIf="user.pluginAuth">{{ user.pluginAuth }}</ng-container>
+      </td>
+
       <td [title]="user.createdAt">{{ user.createdAt }}</td>
+
       <td class="action-cell">
         <my-user-moderation-dropdown *ngIf="!isInSelectionMode()" [user]="user" (userChanged)="onUserChanged()" (userDeleted)="onUserChanged()">
         </my-user-moderation-dropdown>
index 76c57d2fb840037337b494a856fb7bb3ed3a1273..3f6743befbd901435f3da560bc038973c931d22e 100644 (file)
@@ -69,6 +69,8 @@ export class User implements UserServerModel {
   noInstanceConfigWarningModal: boolean
   noWelcomeModal: boolean
 
+  pluginAuth: string | null
+
   createdAt: Date
 
   constructor (hash: Partial<UserServerModel>) {
@@ -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)
     }
index 1bff955df06306f2d6c22a385b1d7df53a57d183..260c1b28eba443921817f28a31ab01cb17b4aef6 100644 (file)
@@ -806,7 +806,9 @@ export class UserModel extends Model<UserModel> {
 
       videoChannels: [],
 
-      createdAt: this.createdAt
+      createdAt: this.createdAt,
+
+      pluginAuth: this.pluginAuth
     }
 
     if (parameters.withAdminFlags) {
index 97df4c1fd50c2d25536f3b761b89a7e9a10ae2bf..cbba638c2bab3788fbe39509fe9f8f21155cd916 100644 (file)
@@ -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 ])
   })
index a9c9bce30da1464ceab717f0e9db6424cd7fa7dc..42be042894b4e2249831faf921f30ad131668d22 100644 (file)
@@ -50,6 +50,8 @@ export interface User {
   noWelcomeModal: boolean
 
   createdAt: Date
+
+  pluginAuth: string | null
 }
 
 export interface MyUserSpecialPlaylist {