mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 18:27:05 +00:00
Merge branches 'dev' and 'dev' of https://github.com/SyncrowIOT/backend into dev
This commit is contained in:
@ -11,6 +11,8 @@ import { UserSessionRepository } from '../../../../common/src/modules/session/re
|
||||
import { UserSessionEntity } from '../../../../common/src/modules/session/entities';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { OAuth2Client } from 'google-auth-library';
|
||||
import { PlatformType } from '@app/common/constants/platform-type.enum';
|
||||
import { RoleType } from '@app/common/constants/role.type.enum';
|
||||
|
||||
@Injectable()
|
||||
export class AuthService {
|
||||
@ -29,6 +31,7 @@ export class AuthService {
|
||||
email: string,
|
||||
pass: string,
|
||||
regionUuid?: string,
|
||||
platform?: PlatformType,
|
||||
): Promise<any> {
|
||||
const user = await this.userRepository.findOne({
|
||||
where: {
|
||||
@ -37,7 +40,13 @@ export class AuthService {
|
||||
},
|
||||
relations: ['roleType'],
|
||||
});
|
||||
|
||||
if (
|
||||
platform === PlatformType.WEB &&
|
||||
(user.roleType.type === RoleType.SPACE_OWNER ||
|
||||
user.roleType.type === RoleType.SPACE_MEMBER)
|
||||
) {
|
||||
throw new UnauthorizedException('Access denied for web platform');
|
||||
}
|
||||
if (!user) {
|
||||
throw new BadRequestException('Invalid credentials');
|
||||
}
|
||||
|
4
libs/common/src/constants/platform-type.enum.ts
Normal file
4
libs/common/src/constants/platform-type.enum.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export enum PlatformType {
|
||||
WEB = 'web',
|
||||
MOBILE = 'mobile',
|
||||
}
|
Reference in New Issue
Block a user