mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
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:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user