Revert "Add Turnstile captcha to login"
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 52s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 52s
This reverts commit 5aa1be27bb.
This commit is contained in:
@@ -55,30 +55,27 @@ const buildDateRangeParams = (dateRange: DateRange) => new URLSearchParams({
|
||||
end: formatDateParam(dateRange.end)
|
||||
});
|
||||
|
||||
export type LoginResult = 'success' | 'invalid_credentials' | 'captcha_failed' | 'server_error';
|
||||
|
||||
export const login = async (email: string, password: string, captchaToken?: string): Promise<LoginResult> => {
|
||||
export const login = async (email: string, password: string): Promise<boolean> => {
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/login`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ email, password, captchaToken }),
|
||||
body: JSON.stringify({ email, password }),
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json() as { token?: string; user?: AuthUser };
|
||||
if (!data.token || !data.user) return 'server_error';
|
||||
if (!data.token || !data.user) return false;
|
||||
localStorage.setItem('auth_token', data.token);
|
||||
localStorage.setItem('auth_user', JSON.stringify(data.user));
|
||||
return 'success';
|
||||
return true;
|
||||
}
|
||||
if (response.status === 403) return 'captcha_failed';
|
||||
return 'invalid_credentials';
|
||||
return false;
|
||||
} catch (error) {
|
||||
console.error('Login failed', error);
|
||||
return 'server_error';
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user