Skip to content

Commit 2da2bea

Browse files
committed
make an api stub for non-backend mode
1 parent 71450d7 commit 2da2bea

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/app/pages/register/register.service.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,24 @@ export class RegisterService {
3636
}
3737

3838
registerUser(payload) {
39-
this.requestRegister();
40-
const creds = payload;
41-
if (creds.email.length > 0 && creds.password.length > 0) {
42-
this.http.post('/user/signup', creds).subscribe(() => {
43-
this.receiveRegister();
44-
this.toastr.success('You\'ve been registered successfully');
45-
this.router.navigate(['/login']);
46-
}, err => {
47-
this.registerError(err.response.data);
48-
});
39+
// We check if app runs with backend mode
40+
if (!this.config.isBackend) {
41+
this.toastr.success('You\'ve been registered successfully');
42+
this.router.navigate(['/login']);
4943
} else {
50-
this.registerError('Something was wrong. Try again');
44+
this.requestRegister();
45+
const creds = payload;
46+
if (creds.email.length > 0 && creds.password.length > 0) {
47+
this.http.post('/user/signup', creds).subscribe(() => {
48+
this.receiveRegister();
49+
this.toastr.success('You\'ve been registered successfully');
50+
this.router.navigate(['/login']);
51+
}, err => {
52+
this.registerError(err.response.data);
53+
});
54+
} else {
55+
this.registerError('Something was wrong. Try again');
56+
}
5157
}
5258
}
5359

0 commit comments

Comments
 (0)