Skip to content

Commit

Permalink
Merge pull request #22 from DevKor-github/hotfix
Browse files Browse the repository at this point in the history
fix: socket error by userSex null
  • Loading branch information
kyeahxx19 authored Nov 15, 2023
2 parents 54de03c + db44dc4 commit 1324988
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/auth/guard/signup.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class SignupGuard extends AuthGuard('signup') {
infoId: userInfo.id,
page: 0,
});
console.log(userInfo.id);
res.json({ signupToken: newToken });
return false;
}
Expand Down
2 changes: 2 additions & 0 deletions src/chat/models/socketUser.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export class SocketUser extends Document {

@Prop({
type: String,
default: undefined,
required: false,
enum: Sex,
})
@IsEnum(Sex)
Expand Down
12 changes: 7 additions & 5 deletions src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,21 @@ export class UserService {
const rand = Math.floor(Math.random() * 100000);
const index = rand % nicknames.length;
const nickname = nicknames[index].toString() + rand.toString();
const user = this.userRepository.create({ userNickname: nickname });
return this.userRepository.save(user);
const user = await this.userRepository.create({ userNickname: nickname });
return await this.userRepository.save(user);
}

async createUserInfo(user: UserEntity) {
const userInfo = this.userInfoRepository.create({ user: user });
return this.userInfoRepository.save(userInfo);
const userInfoEntity = await this.userInfoRepository.create({ user: user });
const userInfo = await this.userInfoRepository.save(userInfoEntity);
this.updateUser(user.id, 'userInfo', userInfo);
return userInfo;
}

async updateUser(
id: number,
field: string,
value: string | BlurtingGroupEntity,
value: string | UserInfoEntity | BlurtingGroupEntity,
) {
const user = await this.userRepository.findOne({ where: { id: id } });
user[field] = value;
Expand Down

0 comments on commit 1324988

Please sign in to comment.