mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 14:49:07 +00:00
Refactor code for consistency; remove unnecessary whitespace and improve formatting in multiple files
This commit is contained in:
parent
98fe5deba7
commit
4982febd74
@ -94,7 +94,9 @@ export default class ProjectMiddleware {
|
||||
// (req as OneUptimeRequest).permissions =
|
||||
// apiKeyModel.permissions || [];
|
||||
(req as OneUptimeRequest).userGlobalAccessPermission =
|
||||
await APIKeyAccessPermission.getDefaultApiGlobalPermission(tenantId);
|
||||
await APIKeyAccessPermission.getDefaultApiGlobalPermission(
|
||||
tenantId,
|
||||
);
|
||||
|
||||
const userTenantAccessPermission: UserTenantAccessPermission | null =
|
||||
await APIKeyAccessPermission.getApiTenantAccessPermission(
|
||||
|
@ -31,7 +31,6 @@ import {
|
||||
} from "Common/Types/Permission";
|
||||
import UserType from "Common/Types/UserType";
|
||||
import Project from "Common/Models/DatabaseModels/Project";
|
||||
import { Socket } from "../Infrastructure/SocketIO";
|
||||
import UserPermissionUtil from "../Utils/UserPermission/UserPermission";
|
||||
|
||||
export default class UserMiddleware {
|
||||
@ -59,8 +58,6 @@ export default class UserMiddleware {
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static getAccessTokenFromExpressRequest(
|
||||
req: ExpressRequest,
|
||||
): string | undefined {
|
||||
|
@ -16,8 +16,6 @@ import TeamPermission from "Common/Models/DatabaseModels/TeamPermission";
|
||||
import UserPermissionUtil from "../Utils/UserPermission/UserPermission";
|
||||
import PermissionNamespace from "../Types/Permission/PermissionNamespace";
|
||||
|
||||
|
||||
|
||||
export class AccessTokenService extends BaseService {
|
||||
public constructor() {
|
||||
super();
|
||||
@ -61,8 +59,6 @@ export class AccessTokenService extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async refreshUserGlobalAccessPermission(
|
||||
userId: ObjectID,
|
||||
): Promise<UserGlobalAccessPermission> {
|
||||
@ -110,16 +106,14 @@ export class AccessTokenService extends BaseService {
|
||||
public async getUserGlobalAccessPermission(
|
||||
userId: ObjectID,
|
||||
): Promise<UserGlobalAccessPermission | null> {
|
||||
const json: UserGlobalAccessPermission | null = await UserPermissionUtil.getUserGlobalAccessPermissionFromCache(
|
||||
userId,
|
||||
)
|
||||
const json: UserGlobalAccessPermission | null =
|
||||
await UserPermissionUtil.getUserGlobalAccessPermissionFromCache(userId);
|
||||
|
||||
if (!json) {
|
||||
return await this.refreshUserGlobalAccessPermission(userId);
|
||||
}
|
||||
|
||||
return json;
|
||||
|
||||
}
|
||||
|
||||
public async refreshUserTenantAccessPermission(
|
||||
|
@ -1,6 +1,6 @@
|
||||
enum PermissionNamespace {
|
||||
GlobalPermission = "global-permissions",
|
||||
ProjectPermission = "project-permissions",
|
||||
}
|
||||
GlobalPermission = "global-permissions",
|
||||
ProjectPermission = "project-permissions",
|
||||
}
|
||||
|
||||
export default PermissionNamespace;
|
||||
export default PermissionNamespace;
|
||||
|
@ -11,7 +11,6 @@ import ApiKeyPermissionService from "../../Services/ApiKeyPermissionService";
|
||||
import UserPermissionUtil from "../UserPermission/UserPermission";
|
||||
|
||||
export default class APIKeyAccessPermission {
|
||||
|
||||
public static async getDefaultApiGlobalPermission(
|
||||
projectId: ObjectID,
|
||||
): Promise<UserGlobalAccessPermission> {
|
||||
@ -26,7 +25,7 @@ export default class APIKeyAccessPermission {
|
||||
};
|
||||
}
|
||||
|
||||
public static async getMasterKeyApiGlobalPermission(
|
||||
public static async getMasterKeyApiGlobalPermission(
|
||||
projectId: ObjectID,
|
||||
): Promise<UserGlobalAccessPermission> {
|
||||
return {
|
||||
@ -60,7 +59,6 @@ export default class APIKeyAccessPermission {
|
||||
return permission;
|
||||
}
|
||||
|
||||
|
||||
public static async getApiTenantAccessPermission(
|
||||
projectId: ObjectID,
|
||||
apiKeyId: ObjectID,
|
||||
|
@ -93,7 +93,8 @@ export default abstract class Realtime {
|
||||
// and to this model and to this event type
|
||||
|
||||
logger.debug("Extracting user access token from socket");
|
||||
const userAccessToken: string | undefined = this.getAccessTokenFromSocket(socket);
|
||||
const userAccessToken: string | undefined =
|
||||
this.getAccessTokenFromSocket(socket);
|
||||
|
||||
if (!userAccessToken) {
|
||||
logger.debug(
|
||||
|
@ -9,7 +9,6 @@ import GlobalCache from "../../Infrastructure/GlobalCache";
|
||||
import PermissionNamespace from "../../Types/Permission/PermissionNamespace";
|
||||
|
||||
export default class UserPermissionUtil {
|
||||
|
||||
public static async getUserTenantAccessPermissionFromCache(
|
||||
userId: ObjectID,
|
||||
projectId: ObjectID,
|
||||
@ -40,7 +39,7 @@ export default class UserPermissionUtil {
|
||||
);
|
||||
|
||||
if (!json) {
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
const accessPermission: UserGlobalAccessPermission =
|
||||
|
@ -1,5 +1,4 @@
|
||||
|
||||
Error.stackTraceLimit = Infinity
|
||||
Error.stackTraceLimit = Infinity;
|
||||
|
||||
import WorkflowRoutes from "./Routes";
|
||||
import { PromiseVoidFunction } from "Common/Types/FunctionTypes";
|
||||
@ -13,7 +12,6 @@ import Redis from "Common/Server/Infrastructure/Redis";
|
||||
import { ClickhouseAppInstance } from "Common/Server/Infrastructure/ClickhouseDatabase";
|
||||
import "ejs";
|
||||
|
||||
|
||||
const APP_NAME: string = "workflow";
|
||||
|
||||
const init: PromiseVoidFunction = async (): Promise<void> => {
|
||||
|
Loading…
Reference in New Issue
Block a user