Skip to content

Commit

Permalink
Merge pull request #2179 from ever-co/2177-fix-redirect-into-login-again
Browse files Browse the repository at this point in the history
fix(Authentication): fix the authentication issue of re route to login
  • Loading branch information
evereq authored Feb 8, 2024
2 parents fe605d9 + 4b682a9 commit c6246ea
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apps/web/app/hooks/auth/useAuthenticationPasscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { AxiosError, isAxiosError } from 'axios';
import { usePathname, useSearchParams } from 'next/navigation';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useQuery } from '../useQuery';
import { useRouter } from 'next/navigation';

type AuthCodeRef = {
focus: () => void;
Expand All @@ -22,7 +23,6 @@ type AuthCodeRef = {
export function useAuthenticationPasscode() {
const pathname = usePathname();
const query = useSearchParams();

const queryTeamId = useMemo(() => {
return query?.get('teamId');
}, [query]);
Expand Down Expand Up @@ -51,7 +51,7 @@ export function useAuthenticationPasscode() {
});

const [errors, setErrors] = useState({} as { [x: string]: any });

const router = useRouter();
// Queries
const { queryCall: sendCodeQueryCall, loading: sendCodeLoading } = useQuery(sendAuthCodeAPI);

Expand Down Expand Up @@ -150,8 +150,8 @@ export function useAuthenticationPasscode() {
}) => {
signInWorkspaceQueryCall(email, token, selectedTeam)
.then(() => {
window.location.reload();
setAuthenticated(true);
router.push('/');
})
.catch((err: AxiosError) => {
if (err.response?.status === 400) {
Expand Down

0 comments on commit c6246ea

Please sign in to comment.