|
|
@@ -108,7 +108,7 @@ export class AuthService {
|
|
|
try {
|
|
|
// 1. Get options from backend
|
|
|
const options = await this.http
|
|
|
- .post<any>(`${this.baseUrl}/auth/webauthn-login-options`, { email })
|
|
|
+ .post<any>(`${this.baseUrl}/auth/webauthn-login-options`, { email }, { withCredentials: true, })
|
|
|
.toPromise();
|
|
|
|
|
|
if (!options) {
|
|
|
@@ -128,7 +128,7 @@ export class AuthService {
|
|
|
|
|
|
// 4. POST to backend and verify
|
|
|
const res = await this.http
|
|
|
- .post<AuthResponse>(`${this.baseUrl}/auth/webauthn-login`, loginPayload)
|
|
|
+ .post<AuthResponse>(`${this.baseUrl}/auth/webauthn-login`, loginPayload, { withCredentials: true, })
|
|
|
.toPromise();
|
|
|
|
|
|
if (!res || !res.access_token) {
|
|
|
@@ -150,7 +150,7 @@ export class AuthService {
|
|
|
try {
|
|
|
// 1. Request generic passkey login options from backend
|
|
|
const options = await this.http
|
|
|
- .post<any>(`${this.baseUrl}/auth/webauthn-login-options`, { passkey: true })
|
|
|
+ .post<any>(`${this.baseUrl}/auth/webauthn-login-options`, { passkey: true }, { withCredentials: true, })
|
|
|
.toPromise();
|
|
|
|
|
|
if (!options) throw new Error('Login options not received');
|
|
|
@@ -162,7 +162,7 @@ export class AuthService {
|
|
|
|
|
|
// 3. Send only the credential back — backend must resolve user from credential ID
|
|
|
const res = await this.http
|
|
|
- .post<AuthResponse>(`${this.baseUrl}/auth/webauthn-login`, assertionResponse)
|
|
|
+ .post<AuthResponse>(`${this.baseUrl}/auth/webauthn-login`, assertionResponse, { withCredentials: true, })
|
|
|
.toPromise();
|
|
|
|
|
|
if (!res?.access_token) {
|
|
|
@@ -178,25 +178,6 @@ export class AuthService {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- reportAttendance(url: string): Observable<AuthResponse> {
|
|
|
- let payload = {
|
|
|
- name: this.userName,
|
|
|
- date: new Date()
|
|
|
- }
|
|
|
- console.log(`Posting ${payload.name} to ${url}`)
|
|
|
- return this.http.post<AuthResponse>(`${url}/attendance`, payload);
|
|
|
- }
|
|
|
-
|
|
|
- reportPayment(url: string, verified: boolean): Observable<AuthResponse> {
|
|
|
- let payload = {
|
|
|
- name: this.userName,
|
|
|
- date: new Date(),
|
|
|
- verified: verified
|
|
|
- }
|
|
|
- console.log(`Posting ${payload.name} to ${url}`)
|
|
|
- return this.http.post<AuthResponse>(`${url}/payment`, payload);
|
|
|
- }
|
|
|
-
|
|
|
setUserName(username: string) {
|
|
|
this.userName = username;
|
|
|
localStorage.setItem('auth_name', username);
|