import { Injectable } from '@angular/core'; import { BlackbaudSsoRouteResponse, PasswordStrengthResponse, TokenStatus } from '../typings/auth.typing'; import { HttpRestService } from './http-rest.service'; import { PortalDeterminationService } from './portal-determination.service'; @Injectable({ providedIn: 'root' }) export class AuthService { constructor ( private httpRestService: HttpRestService, private determinationService: PortalDeterminationService ) { } get termsOfServiceLink () { return 'https://solutions.yourcause.com/wp-content/uploads/2021/08/GC-Terms-of-Service22021.pdf'; } get privacyPolicyLink () { return 'https://solutions.yourcause.com/wp-content/uploads/2021/08/GCPrivacyPolicyFeb21.pdf'; } acceptTermsOfService () { const endpoint = this.determinationService.isManager ? 'api/manager/user/AcceptTermsOfService' : 'api/portal/applicant/AcceptTermsOfService'; return this.httpRestService.post(endpoint, {}); } getPasswordStrength (password: string) { return this.httpRestService .post(`/api/token/GetPasswordStrength`, { password }); } resetApplicantPassword (email: string) { return this.httpRestService .post('api/portal/applicant/RequestPasswordChange', { email }); } resendApplicantVerification ( email: string, grantProgramGuid = '' ) { let endpoint = 'api/portal/applicant/ResendConfirmationEmail'; if (!!grantProgramGuid) { endpoint = endpoint + `?grantProgramGuid=${grantProgramGuid}`; } return this.httpRestService.post(endpoint, { email }); } resendManagerVerification (email: string) { return this.httpRestService.post('api/manager/user/resendConfirmationEmail', { email }); } resendPlatformVerification (email: string) { return this.httpRestService.post('api/admin/AdminAccountManagement/resendConfirmationEmail', { email }); } checkIfTokenExpiredManager ( token: string, isResetPassword = false ): Promise { const endpoint = `api/manager/user/GetRegistrationTokenStatus?token=${token}&isResetPassword=${isResetPassword}`; return this.httpRestService.get(endpoint); } checkIfTokenExpiredApplicant ( token: string, isResetPassword = false ): Promise { const endpoint = `api/portal/applicant/GetRegistrationTokenStatus?token=${token}&isResetPassword=${isResetPassword}`; return this.httpRestService.get(endpoint); } checkIfTokenExpiredPlatform ( token: string, isResetPassword = false ): Promise { const endpoint = `api/admin/AdminAccountManagement/GetRegistrationTokenStatus?token=${token}&isResetPassword=${isResetPassword}`; return this.httpRestService.get(endpoint); } getBlackbaudLoginRoute (): Promise { const endpoint = 'api/admin/Sso/SignInUrl'; return this.httpRestService.get(endpoint); } }