aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/clients.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-05-15 22:22:03 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-05-20 09:57:40 +0200
commit65fcc3119c334b75dd13bcfdebf186afdc580a8f (patch)
tree4f2158c61a9b7c3f47cfa233d01413b946ee53c0 /server/controllers/api/clients.js
parentd5f345ed4cfac4e1fa84dcb4fce1cda4d32f9c73 (diff)
downloadPeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.gz
PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.zst
PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.zip
First typescript iteration
Diffstat (limited to 'server/controllers/api/clients.js')
-rw-r--r--server/controllers/api/clients.js41
1 files changed, 0 insertions, 41 deletions
diff --git a/server/controllers/api/clients.js b/server/controllers/api/clients.js
deleted file mode 100644
index cf83cb835..000000000
--- a/server/controllers/api/clients.js
+++ /dev/null
@@ -1,41 +0,0 @@
1'use strict'
2
3const express = require('express')
4
5const constants = require('../../initializers/constants')
6const db = require('../../initializers/database')
7const logger = require('../../helpers/logger')
8
9const router = express.Router()
10
11router.get('/local', getLocalClient)
12
13// Get the client credentials for the PeerTube front end
14function getLocalClient (req, res, next) {
15 const serverHostname = constants.CONFIG.WEBSERVER.HOSTNAME
16 const serverPort = constants.CONFIG.WEBSERVER.PORT
17 let headerHostShouldBe = serverHostname
18 if (serverPort !== 80 && serverPort !== 443) {
19 headerHostShouldBe += ':' + serverPort
20 }
21
22 // Don't make this check if this is a test instance
23 if (process.env.NODE_ENV !== 'test' && req.get('host') !== headerHostShouldBe) {
24 logger.info('Getting client tokens for host %s is forbidden (expected %s).', req.get('host'), headerHostShouldBe)
25 return res.type('json').status(403).end()
26 }
27
28 db.OAuthClient.loadFirstClient(function (err, client) {
29 if (err) return next(err)
30 if (!client) return next(new Error('No client available.'))
31
32 res.json({
33 client_id: client.clientId,
34 client_secret: client.clientSecret
35 })
36 })
37}
38
39// ---------------------------------------------------------------------------
40
41module.exports = router