Getting the user's access token for file upload (#8877)
This commit is contained in:
parent
38ea110755
commit
5f3844aa38
|
@ -103,6 +103,7 @@ import { EventResponse } from "../models/response/event.response";
|
|||
import { ListResponse } from "../models/response/list.response";
|
||||
import { ProfileResponse } from "../models/response/profile.response";
|
||||
import { UserKeyResponse } from "../models/response/user-key.response";
|
||||
import { UserId } from "../types/guid";
|
||||
import { AttachmentRequest } from "../vault/models/request/attachment.request";
|
||||
import { CipherBulkDeleteRequest } from "../vault/models/request/cipher-bulk-delete.request";
|
||||
import { CipherBulkMoveRequest } from "../vault/models/request/cipher-bulk-move.request";
|
||||
|
@ -451,7 +452,13 @@ export abstract class ApiService {
|
|||
end: string,
|
||||
token: string,
|
||||
) => Promise<ListResponse<EventResponse>>;
|
||||
postEventsCollect: (request: EventRequest[]) => Promise<any>;
|
||||
|
||||
/**
|
||||
* Posts events for a user
|
||||
* @param request The array of events to upload
|
||||
* @param userId The optional user id the events belong to. If no user id is provided the active user id is used.
|
||||
*/
|
||||
postEventsCollect: (request: EventRequest[], userId?: UserId) => Promise<any>;
|
||||
|
||||
deleteSsoUser: (organizationId: string) => Promise<void>;
|
||||
getSsoUserIdentifier: () => Promise<string>;
|
||||
|
|
|
@ -118,6 +118,7 @@ import { EnvironmentService } from "../platform/abstractions/environment.service
|
|||
import { PlatformUtilsService } from "../platform/abstractions/platform-utils.service";
|
||||
import { StateService } from "../platform/abstractions/state.service";
|
||||
import { Utils } from "../platform/misc/utils";
|
||||
import { UserId } from "../types/guid";
|
||||
import { AttachmentRequest } from "../vault/models/request/attachment.request";
|
||||
import { CipherBulkDeleteRequest } from "../vault/models/request/cipher-bulk-delete.request";
|
||||
import { CipherBulkMoveRequest } from "../vault/models/request/cipher-bulk-move.request";
|
||||
|
@ -1423,8 +1424,8 @@ export class ApiService implements ApiServiceAbstraction {
|
|||
return new ListResponse(r, EventResponse);
|
||||
}
|
||||
|
||||
async postEventsCollect(request: EventRequest[]): Promise<any> {
|
||||
const authHeader = await this.getActiveBearerToken();
|
||||
async postEventsCollect(request: EventRequest[], userId?: UserId): Promise<any> {
|
||||
const authHeader = await this.tokenService.getAccessToken(userId);
|
||||
const headers = new Headers({
|
||||
"Device-Type": this.deviceType,
|
||||
Authorization: "Bearer " + authHeader,
|
||||
|
|
|
@ -70,7 +70,7 @@ export class EventUploadService implements EventUploadServiceAbstraction {
|
|||
return req;
|
||||
});
|
||||
try {
|
||||
await this.apiService.postEventsCollect(request);
|
||||
await this.apiService.postEventsCollect(request, userId);
|
||||
} catch (e) {
|
||||
this.logService.error(e);
|
||||
// Add the events back to state if there was an error and they were not uploaded.
|
||||
|
|
Loading…
Reference in New Issue