diff --git a/src/modules/auth/dto/register.payload.ts b/src/modules/auth/dto/register.payload.ts index ed13887..a2dd4f9 100644 --- a/src/modules/auth/dto/register.payload.ts +++ b/src/modules/auth/dto/register.payload.ts @@ -21,6 +21,7 @@ export class RegisterPayload { @IsString() avatar: string; + // remove isAdmin in production, this is for testing purposes @ApiProperty() @IsOptional() isAdmin?: boolean; diff --git a/src/modules/auth/strategies/google.strategy.ts b/src/modules/auth/strategies/google.strategy.ts index ba98609..4327203 100644 --- a/src/modules/auth/strategies/google.strategy.ts +++ b/src/modules/auth/strategies/google.strategy.ts @@ -6,7 +6,7 @@ import { EnvConfig } from '../../../config.type'; @Injectable() export class GoogleStrategy extends PassportStrategy(Strategy, 'google') { - constructor(private configService: ConfigService) { + constructor(readonly configService: ConfigService) { super({ clientID: configService.get('GOOGLE_CLIENT_ID'), clientSecret: configService.get('GOOGLE_CLIENT_SECRET'), diff --git a/src/modules/users/users.service.ts b/src/modules/users/users.service.ts index 0f81cd0..72e1aae 100644 --- a/src/modules/users/users.service.ts +++ b/src/modules/users/users.service.ts @@ -6,6 +6,7 @@ import { TUser } from './user.model'; import { RegisterPayload } from '../auth/dto/register.payload'; import * as bcrypt from 'bcrypt'; import { IRequest, TResponse } from '../../common/helper/common-types'; +import { OAuthRegisterPayload } from '../auth/dto/oauth-register-payload'; @Injectable() export class UsersService { @@ -44,6 +45,12 @@ export class UsersService { }); } + async createWithProvider(payload: OAuthRegisterPayload) { + return await this.userModel.create({ + ...payload, + }); + } + async update(id: string, payload: UpdateUserDto): Promise { await this.findOne(id); return await this.userModel.findByIdAndUpdate(id, payload, { @@ -71,7 +78,6 @@ export class UsersService { async findByEmail(email: string): Promise { const user = await this.userModel.findOne({ email }).select('+password'); - if (!user) throw new BadRequestException('User not found'); return user; }