]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/users/users-command.ts
Give moderators access to edit channels (#4608)
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / users / users-command.ts
index 202528b8d37be5272bb7cbb330e717712deaf399..90c5f218340aefe38c9764f41761be7a6d077ab6 100644 (file)
@@ -1,6 +1,7 @@
-import { omit, pick } from 'lodash'
-import { HttpStatusCode } from '@shared/core-utils'
+import { omit } from 'lodash'
+import { pick } from '@shared/core-utils'
 import {
+  HttpStatusCode,
   MyUser,
   ResultList,
   User,
@@ -190,26 +191,27 @@ export class UsersCommand extends AbstractCommand {
     })).then(res => res.user)
   }
 
-  async generate (username: string) {
+  async generate (username: string, role?: UserRole) {
     const password = 'password'
-    const user = await this.create({ username, password })
+    const user = await this.create({ username, password, role })
 
-    const token = await this.server.loginCommand.getAccessToken({ username, password })
+    const token = await this.server.login.getAccessToken({ username, password })
 
     const me = await this.getMyInfo({ token })
 
     return {
       token,
       userId: user.id,
-      userChannelId: me.videoChannels[0].id
+      userChannelId: me.videoChannels[0].id,
+      userChannelName: me.videoChannels[0].name
     }
   }
 
-  async generateUserAndToken (username: string) {
+  async generateUserAndToken (username: string, role?: UserRole) {
     const password = 'password'
-    await this.create({ username, password })
+    await this.create({ username, password, role })
 
-    return this.server.loginCommand.getAccessToken({ username, password })
+    return this.server.login.getAccessToken({ username, password })
   }
 
   register (options: OverrideCommandOptions & {