-
Notifications
You must be signed in to change notification settings - Fork 504
Merge pull request #1006 from nxglabs/sso_main #1851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request implements SSO (Single Sign-On) functionality by adding domain-based access control, improving error handling for prohibited actions, and adding internationalization support for new error messages.
- Moves user creation inside try-catch block for better error handling in signup process
- Adds specific error handling for domain-restricted actions during login with error code 1001
- Introduces admin role detection logic and multi-language support for "action-prohibited" messages
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
apps/OpenSignServer/cloud/parsefunction/usersignup.js | Moves saveUser call inside try-catch block for improved error handling |
apps/OpenSign/src/pages/Login.jsx | Adds specific error handling for domain restriction (error code 1001) |
apps/OpenSign/src/components/Header.jsx | Adds admin role detection logic based on localStorage data |
apps/OpenSign/public/locales/*/translation.json | Adds "action-prohibited" translation strings in 6 languages |
Comments suppressed due to low confidence (1)
apps/OpenSign/src/components/Header.jsx:25
- The hardcoded role string 'contracts_Admin' should be extracted to a constant to improve maintainability and reduce the risk of typos.
"contracts_Admin";
const isAdmin = | ||
localStorage.getItem("Extand_Class") && | ||
JSON.parse(localStorage.getItem("Extand_Class"))?.[0]?.UserRole === | ||
"contracts_Admin"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The complex nested access to localStorage with JSON.parse should be wrapped in a try-catch block to handle potential JSON parsing errors gracefully.
const isAdmin = | |
localStorage.getItem("Extand_Class") && | |
JSON.parse(localStorage.getItem("Extand_Class"))?.[0]?.UserRole === | |
"contracts_Admin"; | |
let isAdmin = false; | |
const extandClass = localStorage.getItem("Extand_Class"); | |
if (extandClass) { | |
try { | |
const parsedData = JSON.parse(extandClass); | |
isAdmin = parsedData?.[0]?.UserRole === "contracts_Admin"; | |
} catch (error) { | |
console.error("Error parsing Extand_Class from localStorage:", error); | |
} | |
} |
Copilot uses AI. Check for mistakes.
@@ -125,7 +125,11 @@ function Login() { | |||
} | |||
} catch (error) { | |||
console.error("Error while logging in user", error); | |||
showToast("danger", "Invalid username/password or region"); | |||
if (error?.code === 1001) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number 1001 should be extracted to a named constant to improve code readability and maintainability.
if (error?.code === 1001) { | |
if (error?.code === ERROR_CODE_ACTION_PROHIBITED) { |
Copilot uses AI. Check for mistakes.
No description provided.