aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools/cli.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-13 14:23:01 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 (patch)
tree7a166515e4d57a06eb3c08be569f106ed049988b /server/tools/cli.ts
parentd0a0fa429d4651710ed951a3c11af0219e408964 (diff)
downloadPeerTube-7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0.tar.gz
PeerTube-7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0.tar.zst
PeerTube-7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0.zip
Introduce user command
Diffstat (limited to 'server/tools/cli.ts')
-rw-r--r--server/tools/cli.ts10
1 files changed, 4 insertions, 6 deletions
diff --git a/server/tools/cli.ts b/server/tools/cli.ts
index 3e0e03b97..17c2e8c74 100644
--- a/server/tools/cli.ts
+++ b/server/tools/cli.ts
@@ -3,8 +3,7 @@ import { Netrc } from 'netrc-parser'
3import { join } from 'path' 3import { join } from 'path'
4import { createLogger, format, transports } from 'winston' 4import { createLogger, format, transports } from 'winston'
5import { assignCommands, ServerInfo } from '@shared/extra-utils' 5import { assignCommands, ServerInfo } from '@shared/extra-utils'
6import { getMyUserInformation } from '@shared/extra-utils/users/users' 6import { UserRole } from '@shared/models'
7import { User, UserRole } from '@shared/models'
8import { VideoPrivacy } from '../../shared/models/videos' 7import { VideoPrivacy } from '../../shared/models/videos'
9import { getAppNumber, isTestInstance, root } from '../helpers/core-utils' 8import { getAppNumber, isTestInstance, root } from '../helpers/core-utils'
10 9
@@ -16,16 +15,15 @@ const config = require('application-config')(configName)
16const version = require('../../../package.json').version 15const version = require('../../../package.json').version
17 16
18async function getAdminTokenOrDie (server: ServerInfo, username: string, password: string) { 17async function getAdminTokenOrDie (server: ServerInfo, username: string, password: string) {
19 const accessToken = await server.loginCommand.getAccessToken(username, password) 18 const token = await server.loginCommand.getAccessToken(username, password)
20 const resMe = await getMyUserInformation(server.url, accessToken) 19 const me = await server.usersCommand.getMyUserInformation({ token })
21 const me: User = resMe.body
22 20
23 if (me.role !== UserRole.ADMINISTRATOR) { 21 if (me.role !== UserRole.ADMINISTRATOR) {
24 console.error('You must be an administrator.') 22 console.error('You must be an administrator.')
25 process.exit(-1) 23 process.exit(-1)
26 } 24 }
27 25
28 return accessToken 26 return token
29} 27}
30 28
31interface Settings { 29interface Settings {