diff options
author | Sheogorath | 2019-11-20 20:07:35 +0100 |
---|---|---|
committer | GitHub | 2019-11-20 20:07:35 +0100 |
commit | 689f5a0a9583fdd774a271a9e6265ee5356d72a0 (patch) | |
tree | 754bed08f4724a4bc4f91743f6dfe12f92857c01 /lib/web/auth/email | |
parent | f894d3c2fa29865288a31cd80cd2a772ce44b330 (diff) | |
parent | b5ccceff59002034fbb089935076f40b8aa16e58 (diff) |
Merge pull request #213 from davidmehren/refactor_backend_notes
First steps in refactoring the backend code
Diffstat (limited to 'lib/web/auth/email')
-rw-r--r-- | lib/web/auth/email/index.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/web/auth/email/index.js b/lib/web/auth/email/index.js index 32e21428..06560545 100644 --- a/lib/web/auth/email/index.js +++ b/lib/web/auth/email/index.js @@ -9,7 +9,7 @@ const models = require('../../../models') const logger = require('../../../logger') const { setReturnToFromReferer } = require('../utils') const { urlencodedParser } = require('../../utils') -const response = require('../../../response') +const errors = require('../../../errors') let emailAuth = module.exports = Router() @@ -39,8 +39,8 @@ passport.use(new LocalStrategy({ if (config.allowEmailRegister) { emailAuth.post('/register', urlencodedParser, function (req, res, next) { - if (!req.body.email || !req.body.password) return response.errorBadRequest(res) - if (!validator.isEmail(req.body.email)) return response.errorBadRequest(res) + if (!req.body.email || !req.body.password) return errors.errorBadRequest(res) + if (!validator.isEmail(req.body.email)) return errors.errorBadRequest(res) models.User.findOrCreate({ where: { email: req.body.email @@ -63,14 +63,14 @@ if (config.allowEmailRegister) { return res.redirect(config.serverURL + '/') }).catch(function (err) { logger.error('auth callback failed: ' + err) - return response.errorInternalError(res) + return errors.errorInternalError(res) }) }) } emailAuth.post('/login', urlencodedParser, function (req, res, next) { - if (!req.body.email || !req.body.password) return response.errorBadRequest(res) - if (!validator.isEmail(req.body.email)) return response.errorBadRequest(res) + if (!req.body.email || !req.body.password) return errors.errorBadRequest(res) + if (!validator.isEmail(req.body.email)) return errors.errorBadRequest(res) setReturnToFromReferer(req) passport.authenticate('local', { successReturnToOrRedirect: config.serverURL + '/', |