mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
refactor: api key repository (#15491)
This commit is contained in:
parent
1745f48f3d
commit
9a1068c867
12 changed files with 44 additions and 72 deletions
|
|
@ -21,6 +21,7 @@ import { UserEntity } from 'src/entities/user.entity';
|
|||
import { AuthType, ImmichCookie, ImmichHeader, ImmichQuery, Permission } from 'src/enum';
|
||||
import { OAuthProfile } from 'src/interfaces/oauth.interface';
|
||||
import { BaseService } from 'src/services/base.service';
|
||||
import { AuthApiKey } from 'src/types';
|
||||
import { isGranted } from 'src/utils/access';
|
||||
import { HumanReadableSize } from 'src/utils/bytes';
|
||||
|
||||
|
|
@ -309,7 +310,10 @@ export class AuthService extends BaseService {
|
|||
const hashedKey = this.cryptoRepository.hashSha256(key);
|
||||
const apiKey = await this.keyRepository.getKey(hashedKey);
|
||||
if (apiKey) {
|
||||
return { user: apiKey.user, apiKey };
|
||||
return {
|
||||
user: apiKey.user as unknown as UserEntity,
|
||||
apiKey: apiKey as unknown as AuthApiKey,
|
||||
};
|
||||
}
|
||||
|
||||
throw new UnauthorizedException('Invalid API key');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue