feat: adds authentication to ngrx store
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user