Anupriya
commited on
Commit
·
b7b83e1
1
Parent(s):
f8794d4
signin service file modified
Browse files
src/app/home/home.component.ts
CHANGED
|
@@ -130,12 +130,12 @@ export class HomeComponent implements AfterViewInit, OnInit, OnDestroy {
|
|
| 130 |
next: () => {
|
| 131 |
localStorage.removeItem('username');
|
| 132 |
this.showAccountMenu = false;
|
| 133 |
-
this.router.navigate(['/
|
| 134 |
},
|
| 135 |
error: () => {
|
| 136 |
localStorage.removeItem('username');
|
| 137 |
this.showAccountMenu = false;
|
| 138 |
-
this.router.navigate(['/
|
| 139 |
}
|
| 140 |
});
|
| 141 |
}
|
|
|
|
| 130 |
next: () => {
|
| 131 |
localStorage.removeItem('username');
|
| 132 |
this.showAccountMenu = false;
|
| 133 |
+
this.router.navigate(['/sign-in']);
|
| 134 |
},
|
| 135 |
error: () => {
|
| 136 |
localStorage.removeItem('username');
|
| 137 |
this.showAccountMenu = false;
|
| 138 |
+
this.router.navigate(['/sign-in']);
|
| 139 |
}
|
| 140 |
});
|
| 141 |
}
|
src/app/sign-in/sign-in.service.ts
CHANGED
|
@@ -7,14 +7,18 @@ import { catchError } from 'rxjs/operators';
|
|
| 7 |
providedIn: 'root'
|
| 8 |
})
|
| 9 |
export class SignInService {
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
constructor(private http: HttpClient) { }
|
| 12 |
|
| 13 |
signIn(payload: any): Observable<any> {
|
| 14 |
-
return this.http.post(
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
}
|
|
|
|
|
|
|
| 18 |
);
|
| 19 |
}
|
| 20 |
}
|
|
|
|
| 7 |
providedIn: 'root'
|
| 8 |
})
|
| 9 |
export class SignInService {
|
| 10 |
+
private apiUrl = location.hostname.endsWith('hf.space')
|
| 11 |
+
? 'https://pykara-py-learn-backend.hf.space'
|
| 12 |
+
: 'http://localhost:5000';
|
| 13 |
constructor(private http: HttpClient) { }
|
| 14 |
|
| 15 |
signIn(payload: any): Observable<any> {
|
| 16 |
+
return this.http.post(
|
| 17 |
+
`${this.apiUrl}/login`,
|
| 18 |
+
payload,
|
| 19 |
+
{ withCredentials: true } // important for cookies
|
| 20 |
+
).pipe(
|
| 21 |
+
catchError(error => throwError(() => error))
|
| 22 |
);
|
| 23 |
}
|
| 24 |
}
|
src/app/sign-up/sign-up.service.ts
CHANGED
|
@@ -2,14 +2,14 @@ import { Injectable } from '@angular/core';
|
|
| 2 |
import { HttpClient } from '@angular/common/http'; // Import HttpClient for API calls
|
| 3 |
import { Observable } from 'rxjs'; // Import Observable for async handling
|
| 4 |
|
| 5 |
-
@Injectable({
|
| 6 |
-
providedIn: 'root'
|
| 7 |
-
})
|
| 8 |
export class SignUpService {
|
| 9 |
-
private apiUrl =
|
|
|
|
|
|
|
|
|
|
| 10 |
constructor(private http: HttpClient) { }
|
| 11 |
|
| 12 |
-
// Method to sign up a user
|
| 13 |
signUp(payload: any): Observable<any> {
|
| 14 |
return this.http.post(`${this.apiUrl}/sign-up`, payload);
|
| 15 |
}
|
|
|
|
| 2 |
import { HttpClient } from '@angular/common/http'; // Import HttpClient for API calls
|
| 3 |
import { Observable } from 'rxjs'; // Import Observable for async handling
|
| 4 |
|
| 5 |
+
@Injectable({ providedIn: 'root' })
|
|
|
|
|
|
|
| 6 |
export class SignUpService {
|
| 7 |
+
private apiUrl = location.hostname.endsWith('hf.space')
|
| 8 |
+
? 'https://pykara-py-learn-backend.hf.space'
|
| 9 |
+
: 'http://localhost:5000';
|
| 10 |
+
|
| 11 |
constructor(private http: HttpClient) { }
|
| 12 |
|
|
|
|
| 13 |
signUp(payload: any): Observable<any> {
|
| 14 |
return this.http.post(`${this.apiUrl}/sign-up`, payload);
|
| 15 |
}
|