Compare commits
No commits in common. "03a2c7b5466e014504cfe92d50565173c244ff19" and "4bf82275d353126a9dccc52a9d56865dbf1bf886" have entirely different histories.
03a2c7b546
...
4bf82275d3
@ -79,6 +79,7 @@ const TwoFactor = () => {
|
|||||||
if (!code) return;
|
if (!code) return;
|
||||||
|
|
||||||
const result = await post('/api/login/verify', { code });
|
const result = await post('/api/login/verify', { code });
|
||||||
|
console.log(result);
|
||||||
if (result.status === 200) {
|
if (result.status === 200) {
|
||||||
setUser(await fetchUser());
|
setUser(await fetchUser());
|
||||||
return navigate('/home', { replace: true });
|
return navigate('/home', { replace: true });
|
||||||
|
@ -164,30 +164,14 @@ const CreateUserField = () => {
|
|||||||
|
|
||||||
const [link, setLink] = useState(null);
|
const [link, setLink] = useState(null);
|
||||||
const getSignupCode = async () => {
|
const getSignupCode = async () => {
|
||||||
const response = await get('/api/register/code');
|
const response = await get('/api/signup/code');
|
||||||
if (response.status === 200) {
|
if(response.status === 200) setLink(response.data);
|
||||||
const link = `${window.location.origin}/register?code=${response.data.code}`;
|
|
||||||
setLink(link);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const copyToClipboard = (event) => {
|
|
||||||
const text = event.target.innerText;
|
|
||||||
navigator.clipboard.writeText(text);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return <div className="">
|
return <div className="">
|
||||||
{link ?
|
{link ? link : <button onClick={getSignupCode} className="is-center">Create sign-up link</button>}
|
||||||
<span onClick={copyToClipboard}>{link}</span> :
|
|
||||||
<button onClick={getSignupCode} className="is-center">Create sign-up link</button>}
|
|
||||||
|
|
||||||
<form>
|
{/* TODO: Create form */}
|
||||||
<label htmlFor="username">Username</label>
|
|
||||||
<input autoComplete="off" type='text' id='username' />
|
|
||||||
|
|
||||||
<label htmlFor="password">Password</label>
|
|
||||||
<input autoComplete="off" type='password' id='username' />
|
|
||||||
</form>
|
|
||||||
</div>;
|
</div>;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -37,13 +37,13 @@ const parseResponse = async (response) => {
|
|||||||
}, {});
|
}, {});
|
||||||
const success = status >= 200 && status < 300;
|
const success = status >= 200 && status < 300;
|
||||||
const base = { success, status };
|
const base = { success, status };
|
||||||
|
|
||||||
if (status === 401) {
|
|
||||||
clearSession();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (headers['content-type']?.includes('application/json')) {
|
if (headers['content-type']?.includes('application/json')) {
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
if (status === 401) {
|
||||||
|
// const currentPath = window.location.pathname;
|
||||||
|
// if (data.twoFactor && !currentPath.includes('/login/verify')) window.location.pathname = '/login/verify';
|
||||||
|
// else if(!data.twoFactor && !currentPath.includes('/login')) window.location.pathname = '/login';
|
||||||
|
}
|
||||||
return {...base, data};
|
return {...base, data};
|
||||||
}
|
}
|
||||||
return { ...base, message: await response.text() };
|
return { ...base, message: await response.text() };
|
||||||
|
Loading…
Reference in New Issue
Block a user