Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "git",
"url": "https://github.com/PropelAuth/react"
},
"version": "2.0.26",
"version": "2.0.27",
"license": "MIT",
"keywords": [
"auth",
Expand Down
4 changes: 4 additions & 0 deletions src/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export interface InternalAuthState {
getOrgPageUrl(orgId?: string, options?: RedirectToOrgPageOptions): string
getCreateOrgPageUrl(options?: RedirectToCreateOrgOptions): string
getSetupSAMLPageUrl(orgId: string, options?: RedirectToSetupSAMLPageOptions): string

authUrl: string

tokens: Tokens
refreshAuthInfo: () => Promise<void>
defaultDisplayWhileLoading?: React.ReactElement
Expand Down Expand Up @@ -201,6 +204,7 @@ export const AuthProvider = (props: AuthProviderProps) => {
getOrgPageUrl,
getCreateOrgPageUrl,
getSetupSAMLPageUrl,
authUrl,
refreshAuthInfo,
tokens: {
getAccessTokenForOrg,
Expand Down
3 changes: 3 additions & 0 deletions src/AuthContextForTesting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type AuthProviderForTestingProps = {
loading?: boolean
userInformation?: UserInformationForTesting
activeOrgFn?: () => string | null
authUrl?: string
children?: React.ReactNode
}

Expand All @@ -37,6 +38,7 @@ export const AuthProviderForTesting = ({
loading,
userInformation,
activeOrgFn,
authUrl,
children,
}: AuthProviderForTestingProps) => {
const authInfo = getAuthInfoForTesting(userInformation)
Expand Down Expand Up @@ -70,6 +72,7 @@ export const AuthProviderForTesting = ({
getOrgPageUrl: () => "",
getCreateOrgPageUrl: () => "",
getSetupSAMLPageUrl: () => "",
authUrl: authUrl ?? "https://auth.example.com",
activeOrgFn: activeOrgFnWithDefault,
refreshAuthInfo: () => Promise.resolve(),
tokens: {
Expand Down
11 changes: 11 additions & 0 deletions src/hooks/useAuthUrl.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { useContext } from "react"
import { AuthContext } from "../AuthContext"

export function useAuthUrl() {
const context = useContext(AuthContext)
if (context === undefined) {
throw new Error("useAuthUrl must be used within an AuthProvider or RequiredAuthProvider")
}
const { authUrl } = context
return authUrl
}
1 change: 1 addition & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type {
} from "./hooks/additionalHooks"
export { loadOrgSelectionFromLocalStorage, saveOrgSelectionToLocalStorage, useActiveOrg } from "./hooks/useActiveOrg"
export { useAuthInfo } from "./hooks/useAuthInfo"
export { useAuthUrl } from "./hooks/useAuthUrl"
export { useHostedPageUrls } from "./hooks/useHostedPageUrls"
export { useLogoutFunction } from "./hooks/useLogoutFunction"
export { RedirectToLogin, RedirectToSignup, useRedirectFunctions } from "./hooks/useRedirectFunctions"
Expand Down
Loading