Spaces:
Running
Running
Commit
·
cbd4fc9
1
Parent(s):
fc659a3
feat: create workout on register
Browse files
src/modules/users/modules/auth/services/users-auth.service.ts
CHANGED
@@ -5,13 +5,18 @@ import { JwtHelper } from "@helpers/jwt.helper";
|
|
5 |
import { User } from "@common/models/user.model";
|
6 |
import { IUserRegister } from "@common/validations/user-register.validation";
|
7 |
import { CrudService } from "@lib/services/crud.service";
|
|
|
8 |
|
9 |
export class UsersAuthService extends CrudService(User) {
|
|
|
|
|
10 |
async register(createParams: IUserRegister) {
|
11 |
if (createParams.password !== createParams.confirmPassword) {
|
12 |
throw new HttpError(400, "passwords do not match");
|
13 |
}
|
14 |
-
|
|
|
|
|
15 |
}
|
16 |
|
17 |
async login(loginRequest: ILogin) {
|
|
|
5 |
import { User } from "@common/models/user.model";
|
6 |
import { IUserRegister } from "@common/validations/user-register.validation";
|
7 |
import { CrudService } from "@lib/services/crud.service";
|
8 |
+
import { WorkoutService } from "../../workouts/services/workouts.service";
|
9 |
|
10 |
export class UsersAuthService extends CrudService(User) {
|
11 |
+
private workoutsService = new WorkoutService();
|
12 |
+
|
13 |
async register(createParams: IUserRegister) {
|
14 |
if (createParams.password !== createParams.confirmPassword) {
|
15 |
throw new HttpError(400, "passwords do not match");
|
16 |
}
|
17 |
+
const user = await this.create(createParams);
|
18 |
+
await this.workoutsService.createModelWorkout(user);
|
19 |
+
return user;
|
20 |
}
|
21 |
|
22 |
async login(loginRequest: ILogin) {
|