Skip to content

Commit

Permalink
Revert "ISTE-11: Fixed Redirect logout url, Fixed breadcrumb need to …
Browse files Browse the repository at this point in the history
…hide (#424)"

This reverts commit ae27835.
  • Loading branch information
jagankumar-egov committed Jun 10, 2024
1 parent ef1dd9d commit 54645fa
Showing 1 changed file with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ import { Request, ServiceRequest } from "../../atoms/Utils/Request";
import { Storage } from "../../atoms/Utils/Storage";

export const UserService = {
authenticate: async (details) => {
authenticate: async(details) => {
const data = new URLSearchParams();
Object.entries(details).forEach(([key, value]) => data.append(key, value));
data.append("scope", "read");
data.append("grant_type", "password");

let authResponse = await ServiceRequest({
let authResponse= await ServiceRequest({
serviceName: "authenticate",
url: Urls.Authenticate,
data,
headers: {
authorization: `Basic ${window?.globalConfigs?.getConfig("JWT_TOKEN") || "ZWdvdi11c2VyLWNsaWVudDo="}`,
authorization: `Basic ${window?.globalConfigs?.getConfig("JWT_TOKEN")||"ZWdvdi11c2VyLWNsaWVudDo="}`,
"Content-Type": "application/x-www-form-urlencoded",
},
});
const invalidRoles = window?.globalConfigs?.getConfig("INVALIDROLES") || [];
if (invalidRoles && invalidRoles.length > 0 && authResponse && authResponse?.UserRequest?.roles?.some((role) => invalidRoles.includes(role.code))) {
throw new Error("ES_ERROR_USER_NOT_PERMITTED");
}
return authResponse;
const invalidRoles = window?.globalConfigs?.getConfig("INVALIDROLES") || [];
if (invalidRoles && invalidRoles.length > 0 && authResponse && authResponse?.UserRequest?.roles?.some((role) => invalidRoles.includes(role.code))) {
throw new Error("ES_ERROR_USER_NOT_PERMITTED");
}
return authResponse;
},
logoutUser: () => {
let user = UserService.getUser();
Expand All @@ -48,16 +48,18 @@ export const UserService = {
},
logout: async () => {
const userType = UserService.getType();
const logoutRedirectURL = window?.globalConfigs?.getConfig("LOGOUT_REDIRECT_URL") || `/${window?.contextPath}/${userType === "citizen"?"citizen":"employee/user/language-selection"}`;
try {
await UserService.logoutUser();
} catch (e) {
}
finally {
finally{
window.localStorage.clear();
window.sessionStorage.clear();
window.location.replace(`/${logoutRedirectURL}`);

if (userType === "citizen") {
window.location.replace(`/${window?.contextPath}/citizen`);
} else {
window.location.replace(`/${window?.contextPath}/employee/user/language-selection`);
}
}
},
sendOtp: (details, stateCode) =>
Expand Down Expand Up @@ -123,7 +125,7 @@ export const UserService = {
});
},
userSearch: async (tenantId, data, filters) => {

return ServiceRequest({
url: Urls.UserSearch,
params: { ...filters },
Expand Down

0 comments on commit 54645fa

Please sign in to comment.