mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-28 18:12:16 +00:00
* variable parser * rm plugin * set fcn * env * EnvCode component * cleanup env demo * env * rm remark plugin * auth request context * auth req component * authorize endpoint construction * rev react page * fix endpoint * styling * query params with anchor * desc * tailwind coexistence * fix styles * add login_hint, organizationId scope * auth request without prompt * show login_hint * sync displayed url with actual href * fix fcn * coloring * Update docs/src/components/authrequest.jsx Co-authored-by: mffap <[email protected]> * Update docs/src/components/authrequest.jsx Co-authored-by: mffap <[email protected]> * Update docs/src/components/authrequest.jsx Co-authored-by: mffap <[email protected]> * Update docs/src/components/authrequest.jsx Co-authored-by: mffap <[email protected]> * Update docs/src/components/authrequest.jsx Co-authored-by: mffap <[email protected]> * Update docs/src/components/authrequest.jsx Co-authored-by: mffap <[email protected]> * add plausible, header * add pkce * move * adds pkce code challenge * replace cboa * reaname and move to required * fall back to cboa due to webpack error * trailing slash * reorder org_id * remove resourceowner * texts * update references * buffer, fix some react dom components * Apply suggestions from code review Co-authored-by: Florian Forster <[email protected]> * standard scopes Co-authored-by: mffap <[email protected]> Co-authored-by: Florian Forster <[email protected]>
32 lines
924 B
JavaScript
32 lines
924 B
JavaScript
import React, { useState, useEffect } from "react";
|
|
|
|
export const EnvironmentContext = React.createContext(null);
|
|
|
|
export default ({ children }) => {
|
|
const [instance, setInstance] = useState("your-instance");
|
|
const [clientId, setClientId] = useState("your-client-id");
|
|
|
|
useEffect(() => {
|
|
const params = new URLSearchParams(window.location.search); // id=123
|
|
const clientId = params.get("clientId");
|
|
const instance = params.get("instance");
|
|
|
|
const localClientId = localStorage.getItem("clientId");
|
|
const localInstance = localStorage.getItem("instance");
|
|
|
|
setClientId(clientId ?? localClientId ?? "");
|
|
setInstance(instance ?? localInstance ?? "");
|
|
}, []);
|
|
|
|
const environment = {
|
|
instance: [instance, setInstance],
|
|
clientId: [clientId, setClientId],
|
|
};
|
|
|
|
return (
|
|
<EnvironmentContext.Provider value={environment}>
|
|
{children}
|
|
</EnvironmentContext.Provider>
|
|
);
|
|
};
|