feat: adds authentication to ngrx store

This commit is contained in:
2023-01-05 18:05:43 +01:00
parent fb57344b1b
commit 9f09aae467
59 changed files with 1152 additions and 848 deletions

View File

@@ -1,5 +1,5 @@
import {Injectable} from '@angular/core';
import {map, Observable} from "rxjs";
import {catchError, map, Observable, of, throwError} from "rxjs";
import {RegisterAppResponse} from "../interfaces/responses/register_app_response";
import {GetAccessTokenResponse} from "../interfaces/responses/get_access_token_response";
import {VerifyCredentialsResponse} from "../interfaces/responses/verify_credentials_response";
@@ -31,17 +31,20 @@ export class MastodonApiAuthenticationService {
const url = `https://${instance}/api/v1/apps`;
return this.mastodonApiService
.post<RegisterAppResponse>(url, parameters)
.pipe(map((response) => {
return <RegisteredApp>{
id: response.id,
name: response.name,
website: response.website,
redirectUri: response.redirect_uri,
clientId: response.client_id,
clientSecret: response.client_secret,
vapidKey: response.vapid_key,
}
}));
.pipe(
map((response) => {
return <RegisteredApp>{
id: response.id,
name: response.name,
website: response.website,
redirectUri: response.redirect_uri,
clientId: response.client_id,
clientSecret: response.client_secret,
vapidKey: response.vapid_key,
}
}),
catchError((error) => throwError(error)),
);
}
authorizeUser(instance: string, clientId: string, redirectUrl: string) {