mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Check username/password.
This commit is contained in:
parent
20b8f59b76
commit
8bebbca413
2 changed files with 9 additions and 5 deletions
|
|
@ -2,11 +2,15 @@ import { serialize } from 'cookie';
|
|||
import { checkPassword, createSecureToken } from 'lib/crypto';
|
||||
import { getAccountByUsername } from 'lib/queries';
|
||||
import { AUTH_COOKIE_NAME } from 'lib/constants';
|
||||
import { ok, unauthorized } from 'lib/response';
|
||||
import { ok, unauthorized, badRequest } from 'lib/response';
|
||||
|
||||
export default async (req, res) => {
|
||||
const { username, password } = req.body;
|
||||
|
||||
if (!username || !password) {
|
||||
return badRequest(res);
|
||||
}
|
||||
|
||||
const account = await getAccountByUsername(username);
|
||||
|
||||
if (account && (await checkPassword(password, account.password))) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue