aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools/peertube-auth.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-25 13:55:28 +0200
committerChocobozzz <me@florianbigard.com>2019-04-25 13:55:28 +0200
commit2b4dd7e26d93c2d9bef4f365cb03c511eff4ca8f (patch)
tree5fe2982e0db8c1ccb661d5aa9c25b02c12590401 /server/tools/peertube-auth.ts
parent47f6409bb8bc49a50027b9579bb651c0506b6912 (diff)
downloadPeerTube-2b4dd7e26d93c2d9bef4f365cb03c511eff4ca8f.tar.gz
PeerTube-2b4dd7e26d93c2d9bef4f365cb03c511eff4ca8f.tar.zst
PeerTube-2b4dd7e26d93c2d9bef4f365cb03c511eff4ca8f.zip
Fix optional privacy in upload endpoint
Diffstat (limited to 'server/tools/peertube-auth.ts')
-rw-r--r--server/tools/peertube-auth.ts16
1 files changed, 10 insertions, 6 deletions
diff --git a/server/tools/peertube-auth.ts b/server/tools/peertube-auth.ts
index a962944a4..8bc3d332c 100644
--- a/server/tools/peertube-auth.ts
+++ b/server/tools/peertube-auth.ts
@@ -1,22 +1,25 @@
1import * as program from 'commander' 1import * as program from 'commander'
2import * as prompt from 'prompt' 2import * as prompt from 'prompt'
3const Table = require('cli-table') 3import { getSettings, writeSettings, getNetrc } from './cli'
4import { getSettings, writeSettings, netrc } from './cli'
5import { isHostValid } from '../helpers/custom-validators/servers' 4import { isHostValid } from '../helpers/custom-validators/servers'
6import { isUserUsernameValid } from '../helpers/custom-validators/users' 5import { isUserUsernameValid } from '../helpers/custom-validators/users'
7 6
7const Table = require('cli-table')
8
8async function delInstance (url: string) { 9async function delInstance (url: string) {
9 const settings = await getSettings() 10 const [ settings, netrc ] = await Promise.all([ getSettings(), getNetrc() ])
10 11
11 settings.remotes.splice(settings.remotes.indexOf(url)) 12 settings.remotes.splice(settings.remotes.indexOf(url))
12 await writeSettings(settings) 13 await writeSettings(settings)
13 14
14 delete netrc.machines[url] 15 delete netrc.machines[url]
16
15 await netrc.save() 17 await netrc.save()
16} 18}
17 19
18async function setInstance (url: string, username: string, password: string) { 20async function setInstance (url: string, username: string, password: string) {
19 const settings = await getSettings() 21 const [ settings, netrc ] = await Promise.all([ getSettings(), getNetrc() ])
22
20 if (settings.remotes.indexOf(url) === -1) { 23 if (settings.remotes.indexOf(url) === -1) {
21 settings.remotes.push(url) 24 settings.remotes.push(url)
22 } 25 }
@@ -82,12 +85,13 @@ program
82 .command('list') 85 .command('list')
83 .description('lists registered remote instances') 86 .description('lists registered remote instances')
84 .action(async () => { 87 .action(async () => {
85 const settings = await getSettings() 88 const [ settings, netrc ] = await Promise.all([ getSettings(), getNetrc() ])
89
86 const table = new Table({ 90 const table = new Table({
87 head: ['instance', 'login'], 91 head: ['instance', 'login'],
88 colWidths: [30, 30] 92 colWidths: [30, 30]
89 }) 93 })
90 netrc.loadSync() 94
91 settings.remotes.forEach(element => { 95 settings.remotes.forEach(element => {
92 table.push([ 96 table.push([
93 element, 97 element,