Fix error message on login.

This commit is contained in:
Mike Cao 2020-08-19 19:03:42 -07:00
parent c5d7d5dea2
commit b905824d50
3 changed files with 5 additions and 3 deletions

View file

@ -32,10 +32,10 @@ export default function LoginForm() {
const handleSubmit = async ({ username, password }) => {
const response = await post('/api/auth/login', { username, password });
if (response?.token) {
if (typeof response !== 'string') {
await Router.push('/');
} else {
setMessage('Incorrect username/password');
setMessage(response.startsWith('401') ? 'Incorrect username/password' : response);
}
};