]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tools/peertube-auth.ts
Upgrade server tools
[github/Chocobozzz/PeerTube.git] / server / tools / peertube-auth.ts
index e54649002d9475a1178c9dbdc48d0c8ac045ec12..afa19ee085753b8eae0db246aaef1d0d46e8b897 100644 (file)
@@ -3,12 +3,12 @@
 import { registerTSPaths } from '../helpers/register-ts-paths'
 registerTSPaths()
 
-import * as program from 'commander'
-import * as prompt from 'prompt'
-import { getNetrc, getSettings, writeSettings } from './cli'
+import { OptionValues, program } from 'commander'
+import { assignToken, buildServer, getNetrc, getSettings, writeSettings } from './cli'
 import { isUserUsernameValid } from '../helpers/custom-validators/users'
-import { getAccessToken } from '../../shared/extra-utils'
-import * as CliTable3 from 'cli-table3'
+import CliTable3 from 'cli-table3'
+
+import prompt = require('prompt')
 
 async function delInstance (url: string) {
   const [ settings, netrc ] = await Promise.all([ getSettings(), getNetrc() ])
@@ -66,7 +66,7 @@ program
   .option('-U, --username <username>', 'Username')
   .option('-p, --password <token>', 'Password')
   .option('--default', 'add the entry as the new default')
-  .action((options: program.OptionValues) => {
+  .action((options: OptionValues) => {
     /* eslint-disable no-import-assign */
     prompt.override = options
     prompt.start()
@@ -97,7 +97,8 @@ program
         // @see https://github.com/Chocobozzz/PeerTube/issues/3520
         result.url = stripExtraneousFromPeerTubeUrl(result.url)
 
-        await getAccessToken(result.url, result.username, result.password)
+        const server = buildServer(result.url)
+        await assignToken(server, result.username, result.password)
       } catch (err) {
         console.error(err.message)
         process.exit(-1)