API hooks for event added for auth.login (#4255)

* Rotate JPG image on upload #4206

* fixes #3949 width/height generated for gif and tif

* API hooks for event added for auth.login #4079

* updated doc for api hooks for new auth.login event

* Style tweaks

* Update docs

* Tweak docs some more

* Spelling error

* Allow non-required flags and pass to hook

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
This commit is contained in:
Pyll Gomez
2021-02-24 10:37:13 -05:00
committed by GitHub
parent e130e80f50
commit aeb4ec0472
3 changed files with 82 additions and 35 deletions

View File

@@ -21,7 +21,7 @@ const loginSchema = Joi.object({
password: Joi.string().required(),
mode: Joi.string().valid('cookie', 'json'),
otp: Joi.string(),
});
}).unknown();
router.post(
'/login',
@@ -40,19 +40,15 @@ router.post(
const { error } = loginSchema.validate(req.body);
if (error) throw new InvalidPayloadException(error.message);
const { email, password, otp } = req.body;
const mode = req.body.mode || 'json';
const ip = req.ip;
const userAgent = req.get('user-agent');
const { accessToken, refreshToken, expires } = await authenticationService.authenticate({
...req.body,
ip,
userAgent,
email,
password,
otp,
});
const payload = {