Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@frontegg/react-hooks

Package Overview
Dependencies
Maintainers
0
Versions
1083
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@frontegg/react-hooks - npm Package Compare versions

Comparing version 7.4.0-alpha.0 to 7.4.0-alpha.1

3

auth/hooks.d.ts

@@ -80,3 +80,4 @@ import { AuthActions, AuthState } from '@frontegg/redux-store';

*
* Use this `frontegg` hook function to obtain the authenticated user. If the user is not authenticated, this method will immediately redirect the user to the login page. (Primarily intended for embedded mode usage)
* Use this `frontegg` hook function to obtain the authenticated user.
* If the user is not authenticated, this method will immediately redirect the user to the login page.
* To prevent this immediate redirection behavior, use the `useAuthUserOrNull` method.

@@ -83,0 +84,0 @@ */

@@ -1,6 +0,6 @@

import { useContext } from 'react';
import { useContext, useEffect } from 'react';
import { ContextHolder } from '@frontegg/rest-api';
import { FronteggStoreContext, useStore } from '../FronteggStoreContext';
import { useSnapshot } from '../useSnapshot';
import { useShadowDom } from '../common';
import { useRootState } from '../common';
const defaultMapper = {

@@ -82,3 +82,3 @@ state: state => state,

appName
} = useShadowDom();
} = useRootState();
return onRedirectTo || ContextHolder.for(appName).onRedirectTo;

@@ -113,20 +113,34 @@ };

*
* Use this `frontegg` hook function to obtain the authenticated user. If the user is not authenticated, this method will immediately redirect the user to the login page. (Primarily intended for embedded mode usage)
* Use this `frontegg` hook function to obtain the authenticated user.
* If the user is not authenticated, this method will immediately redirect the user to the login page.
* To prevent this immediate redirection behavior, use the `useAuthUserOrNull` method.
*/
export const useAuthUser = () => {
const {
loginUrl,
customLoginUrl
} = useAuthRoutes();
const authRoutes = useAuthRoutes();
const onRedirectTo = useOnRedirectTo();
const loginWithRedirect = useLoginWithRedirectV2();
const {
user
user,
hostedLoginBox
} = useAuth();
const noUser = {};
const isSSR = typeof window === 'undefined';
const noUser = {};
useEffect(() => {
if (user == null && !isSSR) {
if (hostedLoginBox) {
loginWithRedirect({
shouldRedirectToLogin: true
});
} else {
const {
loginUrl,
customLoginUrl
} = authRoutes;
onRedirectTo(customLoginUrl != null ? customLoginUrl : loginUrl, {
refresh: true
});
}
}
}, [hostedLoginBox, user, authRoutes, onRedirectTo, loginWithRedirect]);
if (user == null && !isSSR) {
onRedirectTo(customLoginUrl != null ? customLoginUrl : loginUrl, {
refresh: true
});
return noUser;

@@ -133,0 +147,0 @@ }

@@ -1,2 +0,2 @@

/** @license Frontegg v7.4.0-alpha.0
/** @license Frontegg v7.4.0-alpha.1
*

@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the

@@ -94,3 +94,3 @@ "use strict";

appName
} = (0, _common.useShadowDom)();
} = (0, _common.useRootState)();
return onRedirectTo || _restApi.ContextHolder.for(appName).onRedirectTo;

@@ -127,3 +127,4 @@ };

*
* Use this `frontegg` hook function to obtain the authenticated user. If the user is not authenticated, this method will immediately redirect the user to the login page. (Primarily intended for embedded mode usage)
* Use this `frontegg` hook function to obtain the authenticated user.
* If the user is not authenticated, this method will immediately redirect the user to the login page.
* To prevent this immediate redirection behavior, use the `useAuthUserOrNull` method.

@@ -133,16 +134,29 @@ */

const useAuthUser = () => {
const {
loginUrl,
customLoginUrl
} = useAuthRoutes();
const authRoutes = useAuthRoutes();
const onRedirectTo = useOnRedirectTo();
const loginWithRedirect = useLoginWithRedirectV2();
const {
user
user,
hostedLoginBox
} = useAuth();
const noUser = {};
const isSSR = typeof window === 'undefined';
const noUser = {};
(0, _react.useEffect)(() => {
if (user == null && !isSSR) {
if (hostedLoginBox) {
loginWithRedirect({
shouldRedirectToLogin: true
});
} else {
const {
loginUrl,
customLoginUrl
} = authRoutes;
onRedirectTo(customLoginUrl != null ? customLoginUrl : loginUrl, {
refresh: true
});
}
}
}, [hostedLoginBox, user, authRoutes, onRedirectTo, loginWithRedirect]);
if (user == null && !isSSR) {
onRedirectTo(customLoginUrl != null ? customLoginUrl : loginUrl, {
refresh: true
});
return noUser;

@@ -149,0 +163,0 @@ }

@@ -1,2 +0,2 @@

/** @license Frontegg v7.4.0-alpha.0
/** @license Frontegg v7.4.0-alpha.1
*

@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the

{
"name": "@frontegg/react-hooks",
"version": "7.4.0-alpha.0",
"version": "7.4.0-alpha.1",
"main": "./node/index.js",

@@ -9,4 +9,4 @@ "license": "MIT",

"@babel/runtime": "^7.18.6",
"@frontegg/redux-store": "7.4.0-alpha.0",
"@frontegg/types": "7.4.0-alpha.0",
"@frontegg/redux-store": "7.4.0-alpha.1",
"@frontegg/types": "7.4.0-alpha.1",
"@types/react": "*",

@@ -13,0 +13,0 @@ "@types/react-is": "^17.0.7",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc