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 c803121 commit 765752d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
10 changes: 6 additions & 4 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.2",
"version": "1.0.0",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"typings": "./dist/types/index.d.ts",
Expand Down Expand Up @@ -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",
Expand Down
21 changes: 10 additions & 11 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) => Promise<LoginResponse>
forgotPassword: (email: string, passwordRecoveryUrl?: string) => Promise<void>,
multiFactorLogin: (multiFactorRequest: MultiFactorLoginRequest) => void
forgotPassword: (email: 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,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.")
Expand All @@ -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 {
Expand All @@ -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) => {
Expand Down

0 comments on commit 765752d

Please sign in to comment.