Created
November 16, 2020 13:25
-
-
Save alancasagrande/8cfc20f7eb2941ae80b07b86b517a361 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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