summaryrefslogtreecommitdiff
path: root/lib/web/auth/email/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/web/auth/email/index.js')
-rw-r--r--lib/web/auth/email/index.js14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/web/auth/email/index.js b/lib/web/auth/email/index.js
index 32e21428..78ca933b 100644
--- a/lib/web/auth/email/index.js
+++ b/lib/web/auth/email/index.js
@@ -7,9 +7,8 @@ const LocalStrategy = require('passport-local').Strategy
const config = require('../../../config')
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 +38,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,15 +62,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)
- setReturnToFromReferer(req)
+ if (!req.body.email || !req.body.password) return errors.errorBadRequest(res)
+ if (!validator.isEmail(req.body.email)) return errors.errorBadRequest(res)
passport.authenticate('local', {
successReturnToOrRedirect: config.serverURL + '/',
failureRedirect: config.serverURL + '/',