mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-09 22:57:24 +00:00
add booking points to user table (#461)
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import { PlatformType } from '@app/common/constants/platform-type.enum';
|
||||
import { RoleType } from '@app/common/constants/role.type.enum';
|
||||
import { UserEntity } from '@app/common/modules/user/entities';
|
||||
import {
|
||||
BadRequestException,
|
||||
Injectable,
|
||||
@ -32,7 +33,7 @@ export class AuthService {
|
||||
pass: string,
|
||||
regionUuid?: string,
|
||||
platform?: PlatformType,
|
||||
): Promise<any> {
|
||||
): Promise<Omit<UserEntity, 'password'>> {
|
||||
const user = await this.userRepository.findOne({
|
||||
where: {
|
||||
email,
|
||||
@ -70,8 +71,9 @@ export class AuthService {
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { password, ...result } = user;
|
||||
return result;
|
||||
// const { password, ...result } = user;
|
||||
delete user.password;
|
||||
return user;
|
||||
}
|
||||
|
||||
async createSession(data): Promise<UserSessionEntity> {
|
||||
@ -114,6 +116,7 @@ export class AuthService {
|
||||
hasAcceptedWebAgreement: user.hasAcceptedWebAgreement,
|
||||
hasAcceptedAppAgreement: user.hasAcceptedAppAgreement,
|
||||
project: user?.project,
|
||||
bookingPoints: user?.bookingPoints,
|
||||
};
|
||||
if (payload.googleCode) {
|
||||
const profile = await this.getProfile(payload.googleCode);
|
||||
|
@ -82,6 +82,12 @@ export class UserEntity extends AbstractEntity<UserDto> {
|
||||
})
|
||||
public isActive: boolean;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: Number,
|
||||
})
|
||||
public bookingPoints?: number;
|
||||
|
||||
@Column({ default: false })
|
||||
hasAcceptedWebAgreement: boolean;
|
||||
|
||||
|
@ -1,25 +1,25 @@
|
||||
import { UserRepository } from '../../../libs/common/src/modules/user/repositories';
|
||||
import { RoleType } from '@app/common/constants/role.type.enum';
|
||||
import { differenceInSeconds } from '@app/common/helper/differenceInSeconds';
|
||||
import {
|
||||
BadRequestException,
|
||||
ForbiddenException,
|
||||
Injectable,
|
||||
} from '@nestjs/common';
|
||||
import { UserSignUpDto } from '../dtos/user-auth.dto';
|
||||
import { HelperHashService } from '../../../libs/common/src/helper/services';
|
||||
import { UserLoginDto } from '../dtos/user-login.dto';
|
||||
import { AuthService } from '../../../libs/common/src/auth/services/auth.service';
|
||||
import { UserSessionRepository } from '../../../libs/common/src/modules/session/repositories/session.repository';
|
||||
import { UserOtpRepository } from '../../../libs/common/src/modules/user/repositories/user.repository';
|
||||
import { ForgetPasswordDto, UserOtpDto, VerifyOtpDto } from '../dtos';
|
||||
import { EmailService } from '../../../libs/common/src/util/email.service';
|
||||
import { OtpType } from '../../../libs/common/src/constants/otp-type.enum';
|
||||
import { UserEntity } from '../../../libs/common/src/modules/user/entities/user.entity';
|
||||
import * as argon2 from 'argon2';
|
||||
import { differenceInSeconds } from '@app/common/helper/differenceInSeconds';
|
||||
import { LessThan, MoreThan } from 'typeorm';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import * as argon2 from 'argon2';
|
||||
import { RoleService } from 'src/role/services';
|
||||
import { RoleType } from '@app/common/constants/role.type.enum';
|
||||
import { LessThan, MoreThan } from 'typeorm';
|
||||
import { AuthService } from '../../../libs/common/src/auth/services/auth.service';
|
||||
import { OtpType } from '../../../libs/common/src/constants/otp-type.enum';
|
||||
import { HelperHashService } from '../../../libs/common/src/helper/services';
|
||||
import { UserSessionRepository } from '../../../libs/common/src/modules/session/repositories/session.repository';
|
||||
import { UserEntity } from '../../../libs/common/src/modules/user/entities/user.entity';
|
||||
import { UserRepository } from '../../../libs/common/src/modules/user/repositories';
|
||||
import { UserOtpRepository } from '../../../libs/common/src/modules/user/repositories/user.repository';
|
||||
import { EmailService } from '../../../libs/common/src/util/email.service';
|
||||
import { ForgetPasswordDto, UserOtpDto, VerifyOtpDto } from '../dtos';
|
||||
import { UserSignUpDto } from '../dtos/user-auth.dto';
|
||||
import { UserLoginDto } from '../dtos/user-login.dto';
|
||||
|
||||
@Injectable()
|
||||
export class UserAuthService {
|
||||
@ -108,7 +108,7 @@ export class UserAuthService {
|
||||
|
||||
async userLogin(data: UserLoginDto) {
|
||||
try {
|
||||
let user;
|
||||
let user: Omit<UserEntity, 'password'>;
|
||||
if (data.googleCode) {
|
||||
const googleUserData = await this.authService.login({
|
||||
googleCode: data.googleCode,
|
||||
@ -145,7 +145,7 @@ export class UserAuthService {
|
||||
}
|
||||
const session = await Promise.all([
|
||||
await this.sessionRepository.update(
|
||||
{ userId: user.id },
|
||||
{ userId: user?.['id'] },
|
||||
{
|
||||
isLoggedOut: true,
|
||||
},
|
||||
@ -166,6 +166,7 @@ export class UserAuthService {
|
||||
hasAcceptedAppAgreement: user.hasAcceptedAppAgreement,
|
||||
project: user.project,
|
||||
sessionId: session[1].uuid,
|
||||
bookingPoints: user.bookingPoints,
|
||||
});
|
||||
return res;
|
||||
} catch (error) {
|
||||
@ -347,6 +348,7 @@ export class UserAuthService {
|
||||
userId: user.uuid,
|
||||
uuid: user.uuid,
|
||||
type,
|
||||
bookingPoints: user.bookingPoints,
|
||||
sessionId,
|
||||
});
|
||||
await this.authService.updateRefreshToken(user.uuid, tokens.refreshToken);
|
||||
|
Reference in New Issue
Block a user