mirror of
https://github.com/directus/directus.git
synced 2026-01-29 11:48:15 -05:00
Merge pull request #413 from directus/last_access
Rename last_login to last_access, track on api use
This commit is contained in:
@@ -59,7 +59,7 @@ columns:
|
||||
token:
|
||||
type: string
|
||||
length: 255
|
||||
last_login:
|
||||
last_access:
|
||||
type: timestamp
|
||||
last_page:
|
||||
type: string
|
||||
|
||||
@@ -49,13 +49,9 @@ const authenticate: RequestHandler = asyncHandler(async (req, res, next) => {
|
||||
throw new InvalidCredentialsException();
|
||||
}
|
||||
|
||||
/** @TODO verify user status */
|
||||
|
||||
req.accountability.user = payload.id;
|
||||
req.accountability.role = user.role;
|
||||
req.accountability.admin = user.admin_access === true || user.admin_access == 1;
|
||||
|
||||
return next();
|
||||
} else {
|
||||
// Try finding the user with the provided token
|
||||
const user = await database
|
||||
@@ -77,13 +73,10 @@ const authenticate: RequestHandler = asyncHandler(async (req, res, next) => {
|
||||
req.accountability.admin = user.admin_access === true || user.admin_access == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @TODO
|
||||
* Implement static tokens
|
||||
*
|
||||
* @NOTE
|
||||
* We'll silently ignore wrong tokens. This makes sure we prevent brute-forcing static tokens
|
||||
*/
|
||||
if (req.accountability?.user) {
|
||||
await database('directus_users').update({ last_access: new Date() }).where({ id: req.accountability.user });
|
||||
}
|
||||
|
||||
return next();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user