AW-111-auth-bug
This commit is contained in:
parent
ee65a4aceb
commit
7a77e3f059
@ -40,7 +40,7 @@ function EmailEnterPage({
|
||||
const [isAuth, setIsAuth] = useState(false);
|
||||
const { subPlan } = useParams();
|
||||
const { width: pageWidth, elementRef: pageRef } = useDynamicSize({});
|
||||
const { error, isLoading, authorization } = useAuthentication();
|
||||
const { error, isLoading, token, user, authorization } = useAuthentication();
|
||||
const { gender } = useSelector(selectors.selectQuestionnaire);
|
||||
const activeProductFromStore = useSelector(selectors.selectActiveProduct);
|
||||
const { products } = usePaywall({
|
||||
@ -106,17 +106,34 @@ function EmailEnterPage({
|
||||
source = ESourceAuthorization["aura.moons"];
|
||||
}
|
||||
await authorization(email, source);
|
||||
dispatch(
|
||||
actions.payment.update({
|
||||
activeProduct,
|
||||
})
|
||||
);
|
||||
setIsAuth(true);
|
||||
setTimeout(() => {
|
||||
navigate(redirectUrl);
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (user && token?.length && !isLoading && !error) {
|
||||
dispatch(
|
||||
actions.payment.update({
|
||||
activeProduct,
|
||||
})
|
||||
);
|
||||
setIsAuth(true);
|
||||
const timeout = setTimeout(() => {
|
||||
navigate(redirectUrl);
|
||||
}, 1000);
|
||||
return () => {
|
||||
clearTimeout(timeout);
|
||||
};
|
||||
}
|
||||
}, [
|
||||
activeProduct,
|
||||
dispatch,
|
||||
error,
|
||||
isLoading,
|
||||
navigate,
|
||||
redirectUrl,
|
||||
token?.length,
|
||||
user,
|
||||
]);
|
||||
|
||||
return (
|
||||
<section
|
||||
className={`${styles.page} page`}
|
||||
@ -134,11 +151,11 @@ function EmailEnterPage({
|
||||
</Title>
|
||||
<p className={styles["not-share"]}>{t("we_dont_share")}</p>
|
||||
<EmailInput
|
||||
name="email"
|
||||
value={email}
|
||||
placeholder={t("your_email")}
|
||||
onValid={handleValidEmail}
|
||||
onInvalid={() => setIsValidEmail(false)}
|
||||
name="email"
|
||||
value={email}
|
||||
placeholder={t("your_email")}
|
||||
onValid={handleValidEmail}
|
||||
onInvalid={() => setIsValidEmail(false)}
|
||||
/>
|
||||
<NameInput
|
||||
value={name}
|
||||
|
||||
@ -118,6 +118,7 @@ export const useAuthentication = () => {
|
||||
const authorization = useCallback(async (email: string, source: ESourceAuthorization) => {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
setError(null)
|
||||
const payload = getAuthorizationPayload(email, source);
|
||||
const { token, userId } = await api.authorization(payload);
|
||||
const { user } = await api.getUser({ token });
|
||||
|
||||
Loading…
Reference in New Issue
Block a user