X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftools%2Fpeertube-auth.ts;h=afa19ee085753b8eae0db246aaef1d0d46e8b897;hb=577280e4c0267b869842b68a55c06dbf2a1b3050;hp=e54649002d9475a1178c9dbdc48d0c8ac045ec12;hpb=ba5a8d89bbf049e4afc41543bcc072cccdb02669;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tools/peertube-auth.ts b/server/tools/peertube-auth.ts index e54649002..afa19ee08 100644 --- a/server/tools/peertube-auth.ts +++ b/server/tools/peertube-auth.ts @@ -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') .option('-p, --password ', '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)