Remember page when logging in

pull/3813/head
Kamran Ahmed 2 years ago
parent 9bcf421590
commit 725aa2b092
  1. 7
      src/components/AuthenticationFlow/EmailLoginForm.tsx

@ -3,7 +3,7 @@ import type { FunctionComponent } from 'preact';
import { useState } from 'preact/hooks'; import { useState } from 'preact/hooks';
import { TOKEN_COOKIE_NAME } from '../../lib/constants'; import { TOKEN_COOKIE_NAME } from '../../lib/constants';
import Spinner from '../Spinner'; import Spinner from '../Spinner';
import {httpPost} from "../../lib/http"; import { httpPost } from '../../lib/http';
const EmailLoginForm: FunctionComponent<{}> = () => { const EmailLoginForm: FunctionComponent<{}> = () => {
const [email, setEmail] = useState<string>(''); const [email, setEmail] = useState<string>('');
@ -46,7 +46,10 @@ const EmailLoginForm: FunctionComponent<{}> = () => {
// If the response is ok, we'll set the token in a cookie // If the response is ok, we'll set the token in a cookie
Cookies.set(TOKEN_COOKIE_NAME, data.token); Cookies.set(TOKEN_COOKIE_NAME, data.token);
window.location.href = '/'; // Refreshing will automatically redirect to the relevant page
// Doing this to avoid redirecting to home page from any pages
// such as roadmap, best-practice etc
window.location.reload();
}) })
.catch((err) => { .catch((err) => {
setIsLoading(false); setIsLoading(false);

Loading…
Cancel
Save