Compare commits

..

No commits in common. "03a2c7b5466e014504cfe92d50565173c244ff19" and "4bf82275d353126a9dccc52a9d56865dbf1bf886" have entirely different histories.

3 changed files with 10 additions and 25 deletions

View File

@ -79,6 +79,7 @@ const TwoFactor = () => {
if (!code) return;
const result = await post('/api/login/verify', { code });
console.log(result);
if (result.status === 200) {
setUser(await fetchUser());
return navigate('/home', { replace: true });

View File

@ -164,30 +164,14 @@ const CreateUserField = () => {
const [link, setLink] = useState(null);
const getSignupCode = async () => {
const response = await get('/api/register/code');
if (response.status === 200) {
const link = `${window.location.origin}/register?code=${response.data.code}`;
setLink(link);
}
};
const copyToClipboard = (event) => {
const text = event.target.innerText;
navigator.clipboard.writeText(text);
const response = await get('/api/signup/code');
if(response.status === 200) setLink(response.data);
};
return <div className="">
{link ?
<span onClick={copyToClipboard}>{link}</span> :
<button onClick={getSignupCode} className="is-center">Create sign-up link</button>}
{link ? link : <button onClick={getSignupCode} className="is-center">Create sign-up link</button>}
<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>
{/* TODO: Create form */}
</div>;
};

View File

@ -37,13 +37,13 @@ const parseResponse = async (response) => {
}, {});
const success = status >= 200 && status < 300;
const base = { success, status };
if (status === 401) {
clearSession();
}
if (headers['content-type']?.includes('application/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, message: await response.text() };