🩹 ooconnector: using user token for post to backend (#525)
This commit is contained in:
@@ -4,6 +4,7 @@ config({ path: `.env.${process.env.NODE_ENV || 'development'}.local` });
|
||||
export const {
|
||||
NODE_ENV,
|
||||
SERVER_PORT,
|
||||
SERVER_BIND,
|
||||
SECRET_KEY,
|
||||
CREDENTIALS_ENDPOINT,
|
||||
ONLY_OFFICE_SERVER,
|
||||
@@ -13,8 +14,10 @@ export const {
|
||||
SERVER_ORIGIN,
|
||||
} = process.env;
|
||||
|
||||
export const twakeDriveTokenRefrehPeriodMS = 10 * 60 * 1000;
|
||||
export const onlyOfficeForgottenFilesCheckPeriodMS = 10 * 60 * 1000;
|
||||
export const onlyOfficeConnectivityCheckPeriodMS = 10 * 60 * 1000;
|
||||
const secs = 1000,
|
||||
mins = 60 * secs;
|
||||
|
||||
export const SERVER_TDRIVE_API_PREFIX = '/tdriveApi/1';
|
||||
export const twakeDriveTokenRefrehPeriodMS = 10 * mins;
|
||||
export const onlyOfficeForgottenFilesCheckPeriodMS = 10 * mins;
|
||||
export const onlyOfficeConnectivityCheckPeriodMS = 10 * mins;
|
||||
export const onlyOfficeCallbackTimeoutMS = 10 * secs;
|
||||
|
||||
@@ -76,7 +76,7 @@ class BrowserEditorController {
|
||||
|
||||
let editingSessionKey = null;
|
||||
if (!preview) {
|
||||
editingSessionKey = await driveService.beginEditingSession(company_id, drive_file_id);
|
||||
editingSessionKey = await driveService.beginEditingSession(company_id, drive_file_id, token);
|
||||
//TODO catch error and display to the user when we can't stopped editing
|
||||
|
||||
//TODO Log error with format to be able to set up grafana alert fir such king of errors
|
||||
|
||||
@@ -91,7 +91,7 @@ class ApiService implements IApiService {
|
||||
};
|
||||
|
||||
public post = async <T, R>(params: IApiServiceRequestParams<T>): Promise<R> => {
|
||||
const { url, payload, headers } = params;
|
||||
const { url, token, payload, headers } = params;
|
||||
|
||||
const axiosWithToken = await this.requireAxios();
|
||||
|
||||
@@ -99,6 +99,7 @@ class ApiService implements IApiService {
|
||||
return await axiosWithToken.post(url, payload, {
|
||||
headers: {
|
||||
...headers,
|
||||
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
@@ -49,12 +49,12 @@ class DriveService implements IDriveService {
|
||||
}
|
||||
};
|
||||
|
||||
public async beginEditingSession(company_id: string, drive_file_id: string) {
|
||||
public async beginEditingSession(company_id: string, drive_file_id: string, user_token?: string) {
|
||||
try {
|
||||
const resource = await apiService.post<{}, { editingSessionKey: string }>({
|
||||
url: `/internal/services/documents/v1/companies/${company_id}/item/${drive_file_id}/editing_session`,
|
||||
payload: {
|
||||
editorApplicationId: 'mock_application_id',
|
||||
editorApplicationId: 'tdrive_onlyoffice',
|
||||
},
|
||||
});
|
||||
if (resource?.editingSessionKey) {
|
||||
|
||||
Reference in New Issue
Block a user