enhance error handling for register
This commit is contained in:
@@ -15,6 +15,9 @@ export default (router, tpl) => {
|
||||
const { username, password, password_confirm, token } = req.post;
|
||||
|
||||
const renderError = (msg) => {
|
||||
if (req.headers['x-requested-with'] === 'XMLHttpRequest' || (req.headers.accept && req.headers.accept.includes('application/json'))) {
|
||||
return res.writeHead(200, { 'Content-Type': 'application/json' }).end(JSON.stringify({ success: false, msg }));
|
||||
}
|
||||
return res.reply({
|
||||
body: tpl.render("register", { theme: req.cookies.theme ?? "f0ck", error: msg })
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user