mirror of
https://github.com/PretendoNetwork/website.git
synced 2026-06-20 11:33:29 -05:00
Added error check for login
This commit is contained in:
parent
f3236f26d5
commit
0d2fdeb130
|
|
@ -82,4 +82,27 @@ form.login .register button {
|
|||
|
||||
footer {
|
||||
margin-top: 23px;
|
||||
}
|
||||
|
||||
@keyframes banner-notice {
|
||||
0% {top: -150px}
|
||||
20% {top: 35px}
|
||||
80% {top: 35px}
|
||||
100% {top: -150px}
|
||||
}
|
||||
.banner-notice {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
position: fixed;
|
||||
top: -150px;
|
||||
width: 100%;
|
||||
animation: banner-notice 5s;
|
||||
}
|
||||
.banner-notice div {
|
||||
padding: 4px 36px;
|
||||
border-radius: 5px;
|
||||
z-index: 3;
|
||||
}
|
||||
.banner-notice.error div {
|
||||
background: #A9375B;
|
||||
}
|
||||
|
|
@ -176,16 +176,16 @@ router.get('/', async (request, response) => {
|
|||
});
|
||||
|
||||
router.get('/login', async (request, response) => {
|
||||
const reqLocale = request.locale;
|
||||
const locale = util.getLocale(reqLocale.region, reqLocale.language);
|
||||
|
||||
const localeString = reqLocale.toString();
|
||||
|
||||
response.render('account_login', {
|
||||
const renderData = {
|
||||
layout: 'main',
|
||||
locale,
|
||||
localeString,
|
||||
});
|
||||
locale: util.getLocale(request.locale.region, request.locale.language),
|
||||
localeString: request.locale.toString(),
|
||||
error: request.cookies.error
|
||||
};
|
||||
|
||||
response.clearCookie('error');
|
||||
|
||||
response.render('account_login', renderData);
|
||||
});
|
||||
|
||||
router.post('/login', async (request, response) => {
|
||||
|
|
@ -198,10 +198,8 @@ router.post('/login', async (request, response) => {
|
|||
});
|
||||
|
||||
if (apiResponse.statusCode !== 200) {
|
||||
// TODO: Error message
|
||||
return response.status(apiResponse.statusCode).json({
|
||||
error: 'Bad'
|
||||
});
|
||||
response.cookie('error', apiResponse.body.error);
|
||||
return response.redirect('/account/login');
|
||||
}
|
||||
|
||||
const tokens = apiResponse.body;
|
||||
|
|
|
|||
|
|
@ -31,4 +31,12 @@
|
|||
|
||||
{{> footer }}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{#if error}}
|
||||
<div class="banner-notice error">
|
||||
<div>
|
||||
<p>{{ error }}</p>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
Loading…
Reference in New Issue
Block a user