Fix routing on redirect to creds page
This commit is contained in:
parent
7c8739a57b
commit
e8d8ffacc9
|
@ -3,8 +3,11 @@ import OTPDisplay from 'components/Authenicator/OTPDisplay';
|
|||
import { getAuthCodes } from 'services/authenticator/authenticatorService';
|
||||
import { Button } from '@mui/material';
|
||||
import { CustomError } from 'utils/error';
|
||||
import { PAGES } from 'constants/pages';
|
||||
import { useRouter } from 'next/router';
|
||||
|
||||
const OTPPage = () => {
|
||||
const router = useRouter();
|
||||
const [codes, setCodes] = useState([]);
|
||||
const [searchTerm, setSearchTerm] = useState('');
|
||||
|
||||
|
@ -17,10 +20,12 @@ const OTPPage = () => {
|
|||
})
|
||||
.catch((err) => {
|
||||
if (err.message === CustomError.KEY_MISSING) {
|
||||
window.location.href = '/';
|
||||
router.push({
|
||||
pathname: PAGES.CREDENTIALS,
|
||||
query: { redirectPage: PAGES.AUTHENICATOR },
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
console.error('something wrong here', err);
|
||||
});
|
||||
} catch (error) {
|
||||
|
|
|
@ -30,6 +30,8 @@ import VerifyMasterPasswordForm, {
|
|||
|
||||
export default function Credentials() {
|
||||
const router = useRouter();
|
||||
const routeReidrectPage =
|
||||
router.query.redirectPage?.toString() ?? PAGES.GALLERY;
|
||||
const [keyAttributes, setKeyAttributes] = useState<KeyAttributes>();
|
||||
const appContext = useContext(AppContext);
|
||||
const [user, setUser] = useState<User>();
|
||||
|
@ -85,7 +87,7 @@ export default function Credentials() {
|
|||
await decryptAndStoreToken(key);
|
||||
const redirectURL = appContext.redirectURL;
|
||||
appContext.setRedirectURL(null);
|
||||
router.push(redirectURL ?? PAGES.GALLERY);
|
||||
router.push(redirectURL ?? routeReidrectPage ?? PAGES.GALLERY);
|
||||
} catch (e) {
|
||||
logError(e, 'useMasterPassword failed');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue