mirror of
https://github.com/immich-app/immich
synced 2026-08-22 13:13:05 +00:00
refactor: collapse canActivate into one path
This commit is contained in:
parent
9775b49ff0
commit
d8e0f8df98
1 changed files with 4 additions and 10 deletions
|
|
@ -88,17 +88,11 @@ export class AuthGuard implements CanActivate {
|
|||
async canActivate(context: ExecutionContext): Promise<boolean> {
|
||||
const request = context.switchToHttp().getRequest<AuthRequest>();
|
||||
|
||||
if (request.path.startsWith('/api/yucca')) {
|
||||
request.user = await this.authService.authenticate({
|
||||
headers: request.headers,
|
||||
queryParams: request.query as Record<string, string>,
|
||||
metadata: { adminRoute: true, sharedLinkRoute: false, uri: request.path },
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
const targets = [context.getHandler()];
|
||||
const options = this.reflector.getAllAndOverride<AuthenticatedOptions | undefined>(MetadataKey.AuthRoute, targets);
|
||||
const options = request.path.startsWith('/api/yucca')
|
||||
? { admin: true, permission: undefined }
|
||||
: this.reflector.getAllAndOverride<AuthenticatedOptions | undefined>(MetadataKey.AuthRoute, targets);
|
||||
|
||||
if (!options) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue