Skip to content

Instantly share code, notes, and snippets.

@alancasagrande
Created November 16, 2020 13:25
Show Gist options
  • Save alancasagrande/8cfc20f7eb2941ae80b07b86b517a361 to your computer and use it in GitHub Desktop.
Save alancasagrande/8cfc20f7eb2941ae80b07b86b517a361 to your computer and use it in GitHub Desktop.
export async function login(username, password) {
const res = await fetch('/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password }),
});
if (res.status === 401) {
return { requireMfa: false };
}
if (res.status === 403) {
return { requireMfa: true };
}
const user = await res.json();
return { user, requireMfa: false };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment