Skip to content

Commit

Permalink
Merge pull request #1488 from Puli-shilpa/Dev-2.0
Browse files Browse the repository at this point in the history
fixed session issue
  • Loading branch information
sriranjan-s authored Oct 30, 2024
2 parents ace5638 + 51e5ad0 commit 14f9cc9
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 23 deletions.
6 changes: 3 additions & 3 deletions frontend/micro-ui/web/micro-ui-internals/example/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ const enabledModules = [
const initTokens = (stateCode) => {
const userType = window.sessionStorage.getItem("userType") || process.env.REACT_APP_USER_TYPE || "CITIZEN";

const token = window.localStorage.getItem("token")|| process.env[`REACT_APP_${userType}_TOKEN`];
const token = sessionStorage.getItem("token")|| process.env[`REACT_APP_${userType}_TOKEN`];

const citizenInfo = window.localStorage.getItem("Citizen.user-info")
const citizenInfo = JSON.parse(sessionStorage.getItem("Citizen.user-info"));

const citizenTenantId = window.localStorage.getItem("Citizen.tenant-id") || stateCode;

const employeeInfo = window.localStorage.getItem("Employee.user-info");
const employeeInfo = JSON.parse(sessionStorage.getItem("Employee.user-info"));
const employeeTenantId = window.localStorage.getItem("Employee.tenant-id");

const userTypeInfo = userType === "CITIZEN" || userType === "QACT" ? "citizen" : "employee";
Expand Down
12 changes: 11 additions & 1 deletion frontend/micro-ui/web/micro-ui-internals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@
"packages/modules/commonPt",
"packages/modules/dss",
"packages/modules/pt",
"packages/modules/tl"
"packages/modules/tl",
"packages/modules/bills",
"packages/modules/engagement",
"packages/modules/fsm",
"packages/modules/hrms",
"packages/modules/mCollect",
"packages/modules/noc",
"packages/modules/obps",
"packages/modules/pgr",
"packages/modules/receipts",
"packages/modules/ws"
],
"author": "Abhinav Kushwaha <[email protected]>",
"license": "MIT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const SelectOtp = ({ config, otp, onOtpChange, onResend, onSelect, t, error, use
code_verifier: sessionStorage.getItem("code_verfier_register"),
code: code, module: "REGISTER"
}
console.log("token",code,TokenReq,sessionStorage.getItem("code_verfier_register"))
//console.log("token",code,TokenReq,sessionStorage.getItem("code_verfier_register"))
// const data = await Digit.DigiLockerService.token({TokenReq })

fetch('https://api.digitallocker.gov.in/public/oauth2/1/token', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ const setCitizenDetail = (userObject, token, tenantId) => {
let locale = JSON.parse(sessionStorage.getItem("Digit.initData"))?.value?.selectedLanguage;
localStorage.setItem("Citizen.tenant-id", tenantId);
localStorage.setItem("tenant-id", tenantId);
localStorage.setItem("citizen.userRequestObject", JSON.stringify(userObject));
sessionStorage.setItem("citizen.userRequestObject", JSON.stringify(userObject));
localStorage.setItem("locale", locale);
localStorage.setItem("Citizen.locale", locale);
localStorage.setItem("token", token);
localStorage.setItem("Citizen.token", token);
localStorage.setItem("user-info", JSON.stringify(userObject));
localStorage.setItem("Citizen.user-info", JSON.stringify(userObject));
sessionStorage.setItem("token", token);
sessionStorage.setItem("Citizen.token", token);
sessionStorage.setItem("user-info", JSON.stringify(userObject));
sessionStorage.setItem("Citizen.user-info", JSON.stringify(userObject));
};

const getFromLocation = (state, searchParams) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ const setEmployeeDetail = (userObject, token) => {
let locale = JSON.parse(sessionStorage.getItem("Digit.locale"))?.value || "en_IN";
localStorage.setItem("Employee.tenant-id", userObject?.tenantId);
localStorage.setItem("tenant-id", userObject?.tenantId);
localStorage.setItem("citizen.userRequestObject", JSON.stringify(userObject));
sessionStorage.setItem("citizen.userRequestObject", JSON.stringify(userObject));
localStorage.setItem("locale", locale);
localStorage.setItem("Employee.locale", locale);
localStorage.setItem("token", token);
localStorage.setItem("Employee.token", token);
localStorage.setItem("user-info", JSON.stringify(userObject));
localStorage.setItem("Employee.user-info", JSON.stringify(userObject));
sessionStorage.setItem("token", token);
sessionStorage.setItem("Employee.token", token);
sessionStorage.setItem("user-info", JSON.stringify(userObject));
sessionStorage.setItem("Employee.user-info", JSON.stringify(userObject));
};

const Login = ({ config: propsConfig, t, isDisabled }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ if(window.location.href.includes("code"))
code_verifier: sessionStorage.getItem("code_verfier"),
code: code, module: "PT"
}
console.log("token",code,TokenReq,sessionStorage.getItem("code_verfier"))
// console.log("token",code,TokenReq,sessionStorage.getItem("code_verfier"))
const data = await Digit.DigiLockerService.token({TokenReq })
sessionStorage.setItem("DigiLocker.token1",data?.TokenRes?.access_token)
//sessionStorage.setItem("DigiLocker.token1",data?.)
Expand Down
12 changes: 11 additions & 1 deletion frontend/micro-ui/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@
"micro-ui-internals/packages/modules/commonPt",
"micro-ui-internals/packages/modules/dss",
"micro-ui-internals/packages/modules/pt",
"micro-ui-internals/packages/modules/tl"
"micro-ui-internals/packages/modules/tl",
"micro-ui-internals/packages/modules/bills",
"micro-ui-internals/packages/modules/engagement",
"micro-ui-internals/packages/modules/fsm",
"micro-ui-internals/packages/modules/hrms",
"micro-ui-internals/packages/modules/mcollect",
"micro-ui-internals/packages/modules/noc",
"micro-ui-internals/packages/modules/obps",
"micro-ui-internals/packages/modules/pgr",
"micro-ui-internals/packages/modules/receipts",
"micro-ui-internals/packages/modules/ws"
],
"engines": {
"node": ">=14"
Expand Down
12 changes: 6 additions & 6 deletions frontend/micro-ui/web/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ if (!user || !user.access_token || !user.info) {
return value && value !== "undefined" ? parseValue(value) : null;
}

const token = getFromStorage("token")
const token = sessionStorage.getItem("token")

const citizenToken = getFromStorage("Citizen.token")
const citizenInfo = getFromStorage("Citizen.user-info")
const citizenTenantId = getFromStorage("Citizen.tenant-id")
const citizenToken = sessionStorage.getItem("Citizen.token")
const citizenInfo = sessionStorage.getItem("Citizen.user-info")
const citizenTenantId = sessionStorage.getItem("Citizen.tenant-id")

const employeeToken = getFromStorage("Employee.token")
const employeeInfo = getFromStorage("Employee.user-info")
const employeeToken = sessionStorage.getItem("Employee.token")
const employeeInfo = sessionStorage.getItem("Employee.user-info")
const employeeTenantId = getFromStorage("Employee.tenant-id")

const userType = token === citizenToken ? "citizen" : "employee";
Expand Down

0 comments on commit 14f9cc9

Please sign in to comment.