Skip to content

Commit

Permalink
moving react dependency to peer dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
hashtagnulla committed Sep 25, 2024
1 parent 8a2b4e8 commit c803121
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
10 changes: 4 additions & 6 deletions packages/sn-auth-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sensenet/sn-auth-react",
"version": "1.0.0",
"version": "1.0.2",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"typings": "./dist/types/index.d.ts",
Expand Down Expand Up @@ -30,15 +30,13 @@
},
"peerDependencies": {
"@material-ui/core": "^4.0.0",
"react": ">=16.8.0",
"react-dom": ">=16.8.0"
"react": "^17.0.0 || ^18.0.0",
"react-dom": "^17.0.0 || ^18.0.0"
},
"dependencies": {
"@babel/runtime": "^7.18.9",
"@material-ui/core": "^4.12.4",
"tslib": "^2.4.0",
"react": "^16.13.0",
"react-dom": "^16.13.0"
"tslib": "^2.4.0"
},
"devDependencies": {
"@babel/cli": "^7.14.9",
Expand Down
21 changes: 11 additions & 10 deletions packages/sn-auth-react/src/components/authentication-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export interface AuthenticationContextState {
user: User | null
login: (loginRequest: LoginRequest) => Promise<LoginResponse>
externalLogin: () => void
multiFactorLogin: (multiFactorRequest: MultiFactorLoginRequest) => void
forgotPassword: (email: string) => Promise<void>,
multiFactorLogin: (multiFactorRequest: MultiFactorLoginRequest) => Promise<LoginResponse>
forgotPassword: (email: string, passwordRecoveryUrl?: string) => Promise<void>,
passwordRecovery: (token: string, password: string) => Promise<void>,
changePassword: (password: string) => Promise<void>
logout: () => void
Expand Down Expand Up @@ -137,7 +137,7 @@ export const AuthenticationProvider = (props: AuthenticationProviderProps) => {
}, TOKEN_EXPIRY_THRESHOLD);

return () => clearInterval(intervalId);
}, [isRefreshingToken])
}, [isRefreshingToken])

useEffect(() => {
const refreshToken = async () => {
Expand Down Expand Up @@ -235,12 +235,9 @@ export const AuthenticationProvider = (props: AuthenticationProviderProps) => {
const user = await getUserDetailsApiCall(props.authServerUrl, response.accessToken)
setUser(user)
setUserDetailsStorage(user)

return response
}
else {
throw new Error()
}

return response
}
catch (e) {
console.log("Error during login.")
Expand All @@ -259,6 +256,10 @@ 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 {
Expand All @@ -275,8 +276,8 @@ export const AuthenticationProvider = (props: AuthenticationProviderProps) => {
}
}

const forgotPassword = async (email: string) => {
await forgotPasswordApiCall(props.authServerUrl, { email })
const forgotPassword = async (email: string, passwordRecoveryUrl?: string) => {
await forgotPasswordApiCall(props.authServerUrl, { email, passwordRecoveryUrl })
}

const passwordRecovery = async (token: string, password: string) => {
Expand Down

0 comments on commit c803121

Please sign in to comment.