File tree Expand file tree Collapse file tree 3 files changed +18
-0
lines changed
Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ export interface InternalAuthState {
3737 getOrgPageUrl ( orgId ?: string , options ?: RedirectToOrgPageOptions ) : string
3838 getCreateOrgPageUrl ( options ?: RedirectToCreateOrgOptions ) : string
3939 getSetupSAMLPageUrl ( orgId : string , options ?: RedirectToSetupSAMLPageOptions ) : string
40+
41+ authUrl : string
42+
4043 tokens : Tokens
4144 refreshAuthInfo : ( ) => Promise < void >
4245 defaultDisplayWhileLoading ?: React . ReactElement
@@ -201,6 +204,7 @@ export const AuthProvider = (props: AuthProviderProps) => {
201204 getOrgPageUrl,
202205 getCreateOrgPageUrl,
203206 getSetupSAMLPageUrl,
207+ authUrl,
204208 refreshAuthInfo,
205209 tokens : {
206210 getAccessTokenForOrg,
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ export type AuthProviderForTestingProps = {
2626 loading ?: boolean
2727 userInformation ?: UserInformationForTesting
2828 activeOrgFn ?: ( ) => string | null
29+ authUrl ?: string
2930 children ?: React . ReactNode
3031}
3132
@@ -37,6 +38,7 @@ export const AuthProviderForTesting = ({
3738 loading,
3839 userInformation,
3940 activeOrgFn,
41+ authUrl,
4042 children,
4143} : AuthProviderForTestingProps ) => {
4244 const authInfo = getAuthInfoForTesting ( userInformation )
@@ -70,6 +72,7 @@ export const AuthProviderForTesting = ({
7072 getOrgPageUrl : ( ) => "" ,
7173 getCreateOrgPageUrl : ( ) => "" ,
7274 getSetupSAMLPageUrl : ( ) => "" ,
75+ authUrl : authUrl ?? "https://auth.example.com" ,
7376 activeOrgFn : activeOrgFnWithDefault ,
7477 refreshAuthInfo : ( ) => Promise . resolve ( ) ,
7578 tokens : {
Original file line number Diff line number Diff line change 1+ import { useContext } from "react"
2+ import { AuthContext } from "../AuthContext"
3+
4+ export function useAuthUrl ( ) {
5+ const context = useContext ( AuthContext )
6+ if ( context === undefined ) {
7+ throw new Error ( "useAuthUrl must be used within an AuthProvider or RequiredAuthProvider" )
8+ }
9+ const { authUrl } = context
10+ return authUrl
11+ }
You can’t perform that action at this time.
0 commit comments