Merge branch 'AW-111-auth-bug' into 'develop'
AW-111-auth-bug See merge request witapp/aura-webapp!182
This commit is contained in:
commit
6a965cd1ef
@ -40,7 +40,7 @@ function EmailEnterPage({
|
|||||||
const [isAuth, setIsAuth] = useState(false);
|
const [isAuth, setIsAuth] = useState(false);
|
||||||
const { subPlan } = useParams();
|
const { subPlan } = useParams();
|
||||||
const { width: pageWidth, elementRef: pageRef } = useDynamicSize({});
|
const { width: pageWidth, elementRef: pageRef } = useDynamicSize({});
|
||||||
const { error, isLoading, authorization } = useAuthentication();
|
const { error, isLoading, token, user, authorization } = useAuthentication();
|
||||||
const { gender } = useSelector(selectors.selectQuestionnaire);
|
const { gender } = useSelector(selectors.selectQuestionnaire);
|
||||||
const activeProductFromStore = useSelector(selectors.selectActiveProduct);
|
const activeProductFromStore = useSelector(selectors.selectActiveProduct);
|
||||||
const { products } = usePaywall({
|
const { products } = usePaywall({
|
||||||
@ -106,17 +106,34 @@ function EmailEnterPage({
|
|||||||
source = ESourceAuthorization["aura.moons"];
|
source = ESourceAuthorization["aura.moons"];
|
||||||
}
|
}
|
||||||
await authorization(email, source);
|
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 (
|
return (
|
||||||
<section
|
<section
|
||||||
className={`${styles.page} page`}
|
className={`${styles.page} page`}
|
||||||
@ -134,11 +151,11 @@ function EmailEnterPage({
|
|||||||
</Title>
|
</Title>
|
||||||
<p className={styles["not-share"]}>{t("we_dont_share")}</p>
|
<p className={styles["not-share"]}>{t("we_dont_share")}</p>
|
||||||
<EmailInput
|
<EmailInput
|
||||||
name="email"
|
name="email"
|
||||||
value={email}
|
value={email}
|
||||||
placeholder={t("your_email")}
|
placeholder={t("your_email")}
|
||||||
onValid={handleValidEmail}
|
onValid={handleValidEmail}
|
||||||
onInvalid={() => setIsValidEmail(false)}
|
onInvalid={() => setIsValidEmail(false)}
|
||||||
/>
|
/>
|
||||||
<NameInput
|
<NameInput
|
||||||
value={name}
|
value={name}
|
||||||
|
|||||||
@ -118,6 +118,7 @@ export const useAuthentication = () => {
|
|||||||
const authorization = useCallback(async (email: string, source: ESourceAuthorization) => {
|
const authorization = useCallback(async (email: string, source: ESourceAuthorization) => {
|
||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
setError(null)
|
||||||
const payload = getAuthorizationPayload(email, source);
|
const payload = getAuthorizationPayload(email, source);
|
||||||
const { token, userId } = await api.authorization(payload);
|
const { token, userId } = await api.authorization(payload);
|
||||||
const { user } = await api.getUser({ token });
|
const { user } = await api.getUser({ token });
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user