diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-13 14:23:01 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:18 +0200 |
commit | 7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 (patch) | |
tree | 7a166515e4d57a06eb3c08be569f106ed049988b /server/tools/cli.ts | |
parent | d0a0fa429d4651710ed951a3c11af0219e408964 (diff) | |
download | PeerTube-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.ts | 10 |
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' | |||
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { createLogger, format, transports } from 'winston' | 4 | import { createLogger, format, transports } from 'winston' |
5 | import { assignCommands, ServerInfo } from '@shared/extra-utils' | 5 | import { assignCommands, ServerInfo } from '@shared/extra-utils' |
6 | import { getMyUserInformation } from '@shared/extra-utils/users/users' | 6 | import { UserRole } from '@shared/models' |
7 | import { User, UserRole } from '@shared/models' | ||
8 | import { VideoPrivacy } from '../../shared/models/videos' | 7 | import { VideoPrivacy } from '../../shared/models/videos' |
9 | import { getAppNumber, isTestInstance, root } from '../helpers/core-utils' | 8 | import { getAppNumber, isTestInstance, root } from '../helpers/core-utils' |
10 | 9 | ||
@@ -16,16 +15,15 @@ const config = require('application-config')(configName) | |||
16 | const version = require('../../../package.json').version | 15 | const version = require('../../../package.json').version |
17 | 16 | ||
18 | async function getAdminTokenOrDie (server: ServerInfo, username: string, password: string) { | 17 | async 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 | ||
31 | interface Settings { | 29 | interface Settings { |