Add auth plugin info in users list

pull/2737/head
Chocobozzz 2020-05-05 09:44:53 +02:00
parent e5c86ba7c2
commit 8bb71f2e33
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
5 changed files with 31 additions and 2 deletions

View File

@ -46,6 +46,7 @@
<th i18n>Email</th> <th i18n>Email</th>
<th i18n pSortableColumn="videoQuotaUsed">Video quota <p-sortIcon field="videoQuotaUsed"></p-sortIcon></th> <th i18n pSortableColumn="videoQuotaUsed">Video quota <p-sortIcon field="videoQuotaUsed"></p-sortIcon></th>
<th i18n>Role</th> <th i18n>Role</th>
<th i18n>Auth plugin</th>
<th i18n pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th> <th i18n pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th>
<th style="width: 50px;"></th> <th style="width: 50px;"></th>
</tr> </tr>
@ -97,7 +98,13 @@
<td>{{ user.videoQuotaUsed }} / {{ user.videoQuota }}</td> <td>{{ user.videoQuotaUsed }} / {{ user.videoQuota }}</td>
<td>{{ user.roleLabel }}</td> <td>{{ user.roleLabel }}</td>
<td>
<ng-container *ngIf="user.pluginAuth">{{ user.pluginAuth }}</ng-container>
</td>
<td [title]="user.createdAt">{{ user.createdAt }}</td> <td [title]="user.createdAt">{{ user.createdAt }}</td>
<td class="action-cell"> <td class="action-cell">
<my-user-moderation-dropdown *ngIf="!isInSelectionMode()" [user]="user" (userChanged)="onUserChanged()" (userDeleted)="onUserChanged()"> <my-user-moderation-dropdown *ngIf="!isInSelectionMode()" [user]="user" (userChanged)="onUserChanged()" (userDeleted)="onUserChanged()">
</my-user-moderation-dropdown> </my-user-moderation-dropdown>

View File

@ -69,6 +69,8 @@ export class User implements UserServerModel {
noInstanceConfigWarningModal: boolean noInstanceConfigWarningModal: boolean
noWelcomeModal: boolean noWelcomeModal: boolean
pluginAuth: string | null
createdAt: Date createdAt: Date
constructor (hash: Partial<UserServerModel>) { constructor (hash: Partial<UserServerModel>) {
@ -112,6 +114,8 @@ export class User implements UserServerModel {
this.createdAt = hash.createdAt this.createdAt = hash.createdAt
this.pluginAuth = hash.pluginAuth
if (hash.account !== undefined) { if (hash.account !== undefined) {
this.account = new Account(hash.account) this.account = new Account(hash.account)
} }

View File

@ -806,7 +806,9 @@ export class UserModel extends Model<UserModel> {
videoChannels: [], videoChannels: [],
createdAt: this.createdAt createdAt: this.createdAt,
pluginAuth: this.pluginAuth
} }
if (parameters.withAdminFlags) { if (parameters.withAdminFlags) {

View File

@ -12,7 +12,7 @@ import {
updateMyUser, updateMyUser,
userLogin, userLogin,
wait, wait,
login, refreshToken, getConfig, updatePluginSettings login, refreshToken, getConfig, updatePluginSettings, getUsersList
} from '../../../shared/extra-utils' } from '../../../shared/extra-utils'
import { User, UserRole, ServerConfig } from '@shared/models' import { User, UserRole, ServerConfig } from '@shared/models'
import { expect } from 'chai' import { expect } from 'chai'
@ -225,6 +225,20 @@ describe('Test id and pass auth plugins', function () {
expect(crashAuth).to.not.exist 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 () { after(async function () {
await cleanupTests([ server ]) await cleanupTests([ server ])
}) })

View File

@ -50,6 +50,8 @@ export interface User {
noWelcomeModal: boolean noWelcomeModal: boolean
createdAt: Date createdAt: Date
pluginAuth: string | null
} }
export interface MyUserSpecialPlaylist { export interface MyUserSpecialPlaylist {