Remove ability to create additional API keys with an existing API key

This commit is contained in:
Tom Moor
2024-06-05 06:53:07 -04:00
parent c9d5ff7ca5
commit 593f7a79b8
2 changed files with 49 additions and 26 deletions

View File

@@ -19,6 +19,8 @@ import {
type AuthenticationOptions = {
/** Role requuired to access the route. */
role?: UserRole;
/** Type of authentication required to access the route. */
type?: AuthenticationType;
/** Authentication is parsed, but optional. */
optional?: boolean;
};
@@ -115,6 +117,10 @@ export default function auth(options: AuthenticationOptions = {}) {
throw AuthorizationError(`${capitalize(options.role)} role required`);
}
if (options.type && type !== options.type) {
throw AuthorizationError(`Invalid authentication type`);
}
// not awaiting the promises here so that the request is not blocked
user.updateActiveAt(ctx).catch((err) => {
Logger.error("Failed to update user activeAt", err);