Account editing and change password.
This commit is contained in:
@@ -24,11 +24,11 @@ export function isValidId(s) {
|
||||
return validate(s);
|
||||
}
|
||||
|
||||
export function hashPassword(password) {
|
||||
export async function hashPassword(password) {
|
||||
return bcrypt.hash(password, SALT_ROUNDS);
|
||||
}
|
||||
|
||||
export function checkPassword(password, hash) {
|
||||
export async function checkPassword(password, hash) {
|
||||
return bcrypt.compare(password, hash);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,18 +8,18 @@ export function redirect(res, url) {
|
||||
return res.status(303).end();
|
||||
}
|
||||
|
||||
export function badRequest(res) {
|
||||
return res.status(400).end();
|
||||
export function badRequest(res, msg) {
|
||||
return res.status(400).end(msg);
|
||||
}
|
||||
|
||||
export function unauthorized(res) {
|
||||
return res.status(401).end();
|
||||
export function unauthorized(res, msg) {
|
||||
return res.status(401).end(msg);
|
||||
}
|
||||
|
||||
export function forbidden(res) {
|
||||
return res.status(403).end();
|
||||
export function forbidden(res, msg) {
|
||||
return res.status(403).end(msg);
|
||||
}
|
||||
|
||||
export function methodNotAllowed(res) {
|
||||
res.status(405).end();
|
||||
export function methodNotAllowed(res, msg) {
|
||||
res.status(405).end(msg);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,12 @@ export const apiRequest = (method, url, body) =>
|
||||
if (res.ok) {
|
||||
return res.json();
|
||||
}
|
||||
return res.text();
|
||||
|
||||
if (['post', 'put', 'delete'].includes(method)) {
|
||||
return res.text();
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
function parseQuery(url, params = {}) {
|
||||
|
||||
Reference in New Issue
Block a user