Merge pull request #617 from mz8i/feature/login-username-warn
Warn of wrong username on login screen
This commit is contained in:
commit
2c9335c1eb
@ -54,8 +54,7 @@ async function createUser(user) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function authUser(username: string, password: string) {
|
async function authUser(username: string, password: string) {
|
||||||
try {
|
const user = await db.oneOrNone(
|
||||||
const user = await db.one(
|
|
||||||
`SELECT
|
`SELECT
|
||||||
user_id,
|
user_id,
|
||||||
(
|
(
|
||||||
@ -73,21 +72,16 @@ async function authUser(username: string, password: string) {
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (user && user.auth_ok) {
|
if (user == undefined) {
|
||||||
|
return { error: 'The username does not exist in the system' };
|
||||||
|
} else if (user.auth_ok) {
|
||||||
if (user.is_blocked) {
|
if (user.is_blocked) {
|
||||||
return { error: `Account temporarily blocked.${user.blocked_reason == undefined ? '' : ' Reason: '+user.blocked_reason}` };
|
return { error: `Account temporarily blocked.${user.blocked_reason == undefined ? '' : ' Reason: '+user.blocked_reason}` };
|
||||||
}
|
}
|
||||||
return { user_id: user.user_id };
|
return { user_id: user.user_id };
|
||||||
} else {
|
} else {
|
||||||
return { error: 'Username or password not recognised' };
|
|
||||||
}
|
|
||||||
} catch(err) {
|
|
||||||
if (err instanceof errors.QueryResultError) {
|
|
||||||
console.error(`Authentication failed for user ${username}`);
|
console.error(`Authentication failed for user ${username}`);
|
||||||
return { error: 'Username or password not recognised' };
|
return { error: 'Username / password pair not recognised' };
|
||||||
}
|
|
||||||
console.error('Error:', err);
|
|
||||||
return { error: 'Database error' };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user