mirror of
https://github.com/bitwarden/browser
synced 2026-02-18 18:33:50 +00:00
feat(tokens): Allow Inactive user authenticated API calls
This commit is contained in:
@@ -1,22 +1,21 @@
|
||||
import { ApiService } from "../../../abstractions/api.service";
|
||||
import { TokenService } from "../../../auth/abstractions/token.service";
|
||||
import { UserId } from "../../../types/guid";
|
||||
import { ConfigApiServiceAbstraction } from "../../abstractions/config/config-api.service.abstraction";
|
||||
import { ServerConfigResponse } from "../../models/response/server-config.response";
|
||||
|
||||
export class ConfigApiService implements ConfigApiServiceAbstraction {
|
||||
constructor(
|
||||
private apiService: ApiService,
|
||||
private tokenService: TokenService,
|
||||
) {}
|
||||
constructor(private apiService: ApiService) {}
|
||||
|
||||
async get(userId: UserId | null): Promise<ServerConfigResponse> {
|
||||
// Authentication adds extra context to config responses, if the user has an access token, we want to use it
|
||||
// We don't particularly care about ensuring the token is valid and not expired, just that it exists
|
||||
const authed: boolean =
|
||||
userId == null ? false : (await this.tokenService.getAccessToken(userId)) != null;
|
||||
let r: any;
|
||||
if (userId == null) {
|
||||
r = await this.apiService.send("GET", "/config", null, false, true);
|
||||
} else {
|
||||
r = await this.apiService.send("GET", "/config", null, userId, true);
|
||||
}
|
||||
|
||||
const r = await this.apiService.send("GET", "/config", null, authed, true);
|
||||
return new ServerConfigResponse(r);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user