Merge branches 'dev' and 'dev' of https://github.com/SyncrowIOT/backend into dev

This commit is contained in:
hannathkadher
2025-01-29 14:55:30 +04:00
4 changed files with 22 additions and 2 deletions

View File

@ -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');
}

View File

@ -0,0 +1,4 @@
export enum PlatformType {
WEB = 'web',
MOBILE = 'mobile',
}