mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-19 08:33:24 +02:00
Make app work with login.
This commit is contained in:
@@ -7,6 +7,7 @@ var logger = require('../../util/logger')
|
||||
var requtil = require('../../util/requtil')
|
||||
var jwtutil = require('../../util/jwtutil')
|
||||
var pathutil = require('../../util/pathutil')
|
||||
var urlutil = require('../../util/urlutil')
|
||||
|
||||
module.exports = function(options) {
|
||||
var log = logger.createLogger('auth-mock')
|
||||
@@ -59,12 +60,6 @@ module.exports = function(options) {
|
||||
requtil.validate(req, function() {
|
||||
req.checkBody('name').notEmpty()
|
||||
req.checkBody('email').isEmail()
|
||||
|
||||
// This is a security risk. Someone might forward the user
|
||||
// to the login page with their own redirect set, and they'd
|
||||
// then be able to steal the token. Some kind of a whitelist
|
||||
// or a fixed redirect URL is needed.
|
||||
req.checkBody('redirect').isUrl()
|
||||
})
|
||||
.then(function() {
|
||||
log.info('Authenticated "%s"', req.body.email)
|
||||
@@ -75,14 +70,12 @@ module.exports = function(options) {
|
||||
}
|
||||
, secret: options.secret
|
||||
})
|
||||
var target = url.parse(req.body.redirect)
|
||||
target.query = {
|
||||
jwt: token
|
||||
}
|
||||
res.status(200)
|
||||
.json({
|
||||
success: true
|
||||
, redirect: url.format(target)
|
||||
, redirect: urlutil.addParams(options.appUrl, {
|
||||
jwt: token
|
||||
})
|
||||
})
|
||||
})
|
||||
.catch(requtil.ValidationError, function(err) {
|
||||
|
||||
Reference in New Issue
Block a user