mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
Transfer repository from Gitlab
This commit is contained in:
21
server/src/decorators/auth-user.decorator.ts
Normal file
21
server/src/decorators/auth-user.decorator.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { createParamDecorator, ExecutionContext } from '@nestjs/common';
|
||||
import { UserEntity } from '../api-v1/user/entities/user.entity';
|
||||
// import { AuthUserDto } from './dto/auth-user.dto';
|
||||
|
||||
export class AuthUserDto {
|
||||
id: string;
|
||||
email: string;
|
||||
}
|
||||
|
||||
export const GetAuthUser = createParamDecorator((data, ctx: ExecutionContext): AuthUserDto => {
|
||||
const req = ctx.switchToHttp().getRequest();
|
||||
|
||||
const { id, email } = req.user as UserEntity;
|
||||
|
||||
const authUser: any = {
|
||||
id: id.toString(),
|
||||
email,
|
||||
};
|
||||
|
||||
return authUser;
|
||||
});
|
||||
Reference in New Issue
Block a user