add more error messages for org access policy

This commit is contained in:
miloschwartz
2026-01-17 12:00:27 -08:00
parent ce632a25cf
commit 2f1756ccf2
2 changed files with 80 additions and 63 deletions

View File

@@ -3,7 +3,7 @@ import { sendToClient } from "#dynamic/routers/ws";
export const OlmErrorCodes = {
OLM_NOT_FOUND: {
code: "OLM_NOT_FOUND",
message: "The requested OLM session could not be found."
message: "The specified device could not be found."
},
CLIENT_ID_NOT_FOUND: {
code: "CLIENT_ID_NOT_FOUND",
@@ -15,15 +15,18 @@ export const OlmErrorCodes = {
},
CLIENT_BLOCKED: {
code: "CLIENT_BLOCKED",
message: "This client has been blocked and cannot connect."
message:
"This client has been blocked in this organization and cannot connect. Please contact your administrator."
},
CLIENT_PENDING: {
code: "CLIENT_PENDING",
message: "This client is pending approval and cannot connect yet."
message:
"This client is pending approval and cannot connect yet. Please contact your administrator."
},
ORG_NOT_FOUND: {
code: "ORG_NOT_FOUND",
message: "The organization could not be found."
message:
"The organization could not be found. Please select a valid organization."
},
USER_ID_NOT_FOUND: {
code: "USER_ID_NOT_FOUND",
@@ -31,23 +34,42 @@ export const OlmErrorCodes = {
},
INVALID_USER_SESSION: {
code: "INVALID_USER_SESSION",
message: "Your user session is invalid or has expired."
message:
"Your user session is invalid or has expired. Please log in again."
},
USER_ID_MISMATCH: {
code: "USER_ID_MISMATCH",
message: "The provided user ID does not match the session."
},
ACCESS_POLICY_DENIED: {
code: "ACCESS_POLICY_DENIED",
message: "Access denied due to policy restrictions."
ORG_ACCESS_POLICY_DENIED: {
code: "ORG_ACCESS_POLICY_DENIED",
message:
"Access to this organization has been denied by policy. Please contact your administrator."
},
ORG_ACCESS_POLICY_PASSWORD_EXPIRED: {
code: "ORG_ACCESS_POLICY_PASSWORD_EXPIRED",
message:
"Access to this organization has been denied because your password has expired. Please visit this organization's dashboard to update your password."
},
ORG_ACCESS_POLICY_SESSION_EXPIRED: {
code: "ORG_ACCESS_POLICY_SESSION_EXPIRED",
message:
"Access to this organization has been denied because your session has expired. Please log in again to refresh the session."
},
ORG_ACCESS_POLICY_2FA_REQUIRED: {
code: "ORG_ACCESS_POLICY_2FA_REQUIRED",
message:
"Access to this organization requires two-factor authentication. Please visit this organization's dashboard to enable two-factor authentication."
},
TERMINATED_REKEYED: {
code: "TERMINATED_REKEYED",
message: "This session was terminated because encryption keys were regenerated."
message:
"This session was terminated because encryption keys were regenerated."
},
TERMINATED_ORG_DELETED: {
code: "TERMINATED_ORG_DELETED",
message: "This session was terminated because the organization was deleted."
message:
"This session was terminated because the organization was deleted."
},
TERMINATED_INACTIVITY: {
code: "TERMINATED_INACTIVITY",
@@ -69,7 +91,7 @@ export const OlmErrorCodes = {
// Helper function to send registration error
export async function sendOlmError(
error: typeof OlmErrorCodes[keyof typeof OlmErrorCodes],
error: (typeof OlmErrorCodes)[keyof typeof OlmErrorCodes],
olmId: string
) {
sendToClient(olmId, {