diff --git a/packages/sn-auth-react/package.json b/packages/sn-auth-react/package.json index bb11774fd..5c9949a41 100644 --- a/packages/sn-auth-react/package.json +++ b/packages/sn-auth-react/package.json @@ -1,6 +1,6 @@ { "name": "@sensenet/sn-auth-react", - "version": "1.0.2", + "version": "1.0.0", "main": "./dist/cjs/index.js", "module": "./dist/esm/index.js", "typings": "./dist/types/index.d.ts", @@ -30,13 +30,15 @@ }, "peerDependencies": { "@material-ui/core": "^4.0.0", - "react": "^17.0.0 || ^18.0.0", - "react-dom": "^17.0.0 || ^18.0.0" + "react": ">=16.8.0", + "react-dom": ">=16.8.0" }, "dependencies": { "@babel/runtime": "^7.18.9", "@material-ui/core": "^4.12.4", - "tslib": "^2.4.0" + "tslib": "^2.4.0", + "react": "^16.13.0", + "react-dom": "^16.13.0" }, "devDependencies": { "@babel/cli": "^7.14.9", diff --git a/packages/sn-auth-react/src/components/authentication-provider.tsx b/packages/sn-auth-react/src/components/authentication-provider.tsx index 37f7bf2aa..a84aa2d91 100644 --- a/packages/sn-auth-react/src/components/authentication-provider.tsx +++ b/packages/sn-auth-react/src/components/authentication-provider.tsx @@ -23,8 +23,8 @@ export interface AuthenticationContextState { user: User | null login: (loginRequest: LoginRequest) => Promise externalLogin: () => void - multiFactorLogin: (multiFactorRequest: MultiFactorLoginRequest) => Promise - forgotPassword: (email: string, passwordRecoveryUrl?: string) => Promise, + multiFactorLogin: (multiFactorRequest: MultiFactorLoginRequest) => void + forgotPassword: (email: string) => Promise, passwordRecovery: (token: string, password: string) => Promise, changePassword: (password: string) => Promise logout: () => void @@ -137,7 +137,7 @@ export const AuthenticationProvider = (props: AuthenticationProviderProps) => { }, TOKEN_EXPIRY_THRESHOLD); return () => clearInterval(intervalId); - }, [isRefreshingToken]) + }, [isRefreshingToken]) useEffect(() => { const refreshToken = async () => { @@ -235,9 +235,12 @@ export const AuthenticationProvider = (props: AuthenticationProviderProps) => { const user = await getUserDetailsApiCall(props.authServerUrl, response.accessToken) setUser(user) setUserDetailsStorage(user) - } - return response + return response + } + else { + throw new Error() + } } catch (e) { console.log("Error during login.") @@ -256,10 +259,6 @@ export const AuthenticationProvider = (props: AuthenticationProviderProps) => { if (response.accessToken && response.refreshToken) { setAccessAndRefreshToken(response.accessToken, response.refreshToken) - const user = await getUserDetailsApiCall(props.authServerUrl, response.accessToken) - setUser(user) - setUserDetailsStorage(user); - return response; } else { @@ -276,8 +275,8 @@ export const AuthenticationProvider = (props: AuthenticationProviderProps) => { } } - const forgotPassword = async (email: string, passwordRecoveryUrl?: string) => { - await forgotPasswordApiCall(props.authServerUrl, { email, passwordRecoveryUrl }) + const forgotPassword = async (email: string) => { + await forgotPasswordApiCall(props.authServerUrl, { email }) } const passwordRecovery = async (token: string, password: string) => {