29/09/2023 - 22h22
parent
9a75e42810
commit
a1c1046dbf
|
@ -235,6 +235,33 @@ const Partner = (props) => {
|
|||
}
|
||||
|
||||
|
||||
// Cette fonction recuperer les droits d'acces stocké en cookie
|
||||
const [connected_user_access_right, setconnected_user_access_right] = React.useState(null);
|
||||
function retrieve_user_acces_right() {
|
||||
const stored_cookie = getCookie('tokenmysypart');
|
||||
var acces_right_token_name = stored_cookie + "_uar";
|
||||
|
||||
var acces_right_token_val = getCookie(acces_right_token_name, { path: '/' });
|
||||
|
||||
var tab_json_access_right = JSON.parse(acces_right_token_val);
|
||||
|
||||
setconnected_user_access_right(tab_json_access_right);
|
||||
|
||||
}
|
||||
|
||||
// check du droit d'acces de l'utilisateur
|
||||
function check_user_acces_right(local_module, local_action) {
|
||||
|
||||
//console.log(" #### check_user_acces_right = ", local_module, " --- local_action = ", local_action);
|
||||
for (let i = 0; i < connected_user_access_right.length; i++) {
|
||||
if (String(connected_user_access_right[i].module) === String(local_module)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
setapiexcelimportmessage();
|
||||
|
@ -270,6 +297,7 @@ const Partner = (props) => {
|
|||
GetPartnerNameFromToken();
|
||||
setformation_file_name();
|
||||
GetPartnerLMSData();
|
||||
retrieve_user_acces_right();
|
||||
}, [])
|
||||
|
||||
|
||||
|
@ -327,17 +355,30 @@ const Partner = (props) => {
|
|||
}
|
||||
|
||||
function pricing_func(event) {
|
||||
var security_retval = check_user_acces_right("prix", "read");
|
||||
|
||||
if (security_retval === 1) {
|
||||
setmenu("pricing");
|
||||
setapiexcelimportmessage();
|
||||
setformation_file_name();
|
||||
history.push("/Partner/pricing");
|
||||
} else {
|
||||
alert("Vous droits ne sont pas suffisants");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function mes_clients_func(event) {
|
||||
var security_retval = check_user_acces_right("client", "read");
|
||||
|
||||
if (security_retval === 1) {
|
||||
setmenu("mes_clients");
|
||||
setapiexcelimportmessage();
|
||||
setformation_file_name();
|
||||
history.push("/Partner/mes_clients");
|
||||
} else {
|
||||
alert("Vous droits ne sont pas suffisants");
|
||||
}
|
||||
}
|
||||
|
||||
function mes_devis_func(event) {
|
||||
|
@ -1001,7 +1042,7 @@ const Partner = (props) => {
|
|||
{String(menu) === "infopartner" &&
|
||||
<div className="div_droite">
|
||||
|
||||
<PartnerInfo />
|
||||
<PartnerInfo check_user_acces_right={check_user_acces_right} />
|
||||
|
||||
</div>
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ function SignIn() {
|
|||
|
||||
//acces_right_token_val = [{'key1':'val1'}, {'key2':'val2'}];
|
||||
|
||||
console.log(" acces_right_token_val = ", acces_right_token_val);
|
||||
///console.log(" acces_right_token_val = ", acces_right_token_val);
|
||||
|
||||
setCookie_acces_right(acces_right_token_name, acces_right_token_val, { path: '/' });
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import Partner_Securite_Data from "./Partner_Securite_Data";
|
|||
import Partner_Invoicing_Data from "./Partner_Invoicing_Data";
|
||||
|
||||
|
||||
function UpdateParnterInfo() {
|
||||
function UpdateParnterInfo(props) {
|
||||
const history = useHistory();
|
||||
const [myApiResponse, setmyApiResponse] = useState("");
|
||||
const [result, setResult] = useState("");
|
||||
|
@ -1549,7 +1549,13 @@ function UpdateParnterInfo() {
|
|||
}
|
||||
|
||||
async function submenu_donnee_securite() {
|
||||
|
||||
var security_retval = props.check_user_acces_right("account_securite", "read");
|
||||
|
||||
if (security_retval === 1)
|
||||
setsubmenu("submenu_donnee_securite");
|
||||
else
|
||||
alert("Vous droits ne sont pas suffisants");
|
||||
}
|
||||
|
||||
async function submenu_contact() {
|
||||
|
|
Loading…
Reference in New Issue