|
@@ -4,7 +4,6 @@ import { Router } from '@angular/router';
|
|
|
import { Observable } from 'rxjs';
|
|
import { Observable } from 'rxjs';
|
|
|
import { AuthResponse, LoginPayload, RegisterPayload } from '../interfaces/interface';
|
|
import { AuthResponse, LoginPayload, RegisterPayload } from '../interfaces/interface';
|
|
|
import { AuthenticationResponseJSON, RegistrationResponseJSON, startAuthentication, startRegistration } from '@simplewebauthn/browser';
|
|
import { AuthenticationResponseJSON, RegistrationResponseJSON, startAuthentication, startRegistration } from '@simplewebauthn/browser';
|
|
|
-import { A11yModule } from '@angular/cdk/a11y';
|
|
|
|
|
import { webConfig } from '../config';
|
|
import { webConfig } from '../config';
|
|
|
|
|
|
|
|
@Injectable({ providedIn: 'root' })
|
|
@Injectable({ providedIn: 'root' })
|
|
@@ -23,7 +22,6 @@ export class AuthService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// -- API Calls --
|
|
// -- API Calls --
|
|
|
-
|
|
|
|
|
register(payload: RegisterPayload): Observable<AuthResponse> {
|
|
register(payload: RegisterPayload): Observable<AuthResponse> {
|
|
|
return new Observable<AuthResponse>((observer) => {
|
|
return new Observable<AuthResponse>((observer) => {
|
|
|
this.http.post<AuthResponse>(`${this.baseUrl}/auth/register`, payload)
|
|
this.http.post<AuthResponse>(`${this.baseUrl}/auth/register`, payload)
|
|
@@ -66,7 +64,7 @@ export class AuthService {
|
|
|
return new Promise(async (resolve, reject) => {
|
|
return new Promise(async (resolve, reject) => {
|
|
|
|
|
|
|
|
const options = await this.http
|
|
const options = await this.http
|
|
|
- .post<any>(`${this.baseUrl}/auth/webauthn-register-options`, { username })
|
|
|
|
|
|
|
+ .post<any>(`${this.baseUrl}/auth/webauthn-register-options`, { username }, { withCredentials: true, })
|
|
|
.toPromise();
|
|
.toPromise();
|
|
|
|
|
|
|
|
if (!options) {
|
|
if (!options) {
|
|
@@ -92,7 +90,7 @@ export class AuthService {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// POST to /webauthn/register
|
|
// POST to /webauthn/register
|
|
|
- this.http.post<AuthResponse>(`${this.baseUrl}/auth/webauthn-register`, credentialJSON).toPromise().then(res => {
|
|
|
|
|
|
|
+ this.http.post<AuthResponse>(`${this.baseUrl}/auth/webauthn-register`, credentialJSON, { withCredentials: true, }).toPromise().then(res => {
|
|
|
if (!res) {
|
|
if (!res) {
|
|
|
reject(res)
|
|
reject(res)
|
|
|
} else {
|
|
} else {
|