mirror of
https://github.com/PretendoNetwork/website.git
synced 2026-09-07 08:26:37 -05:00
password reset frontend
This commit is contained in:
@@ -40,6 +40,24 @@ function login() {
|
||||
}
|
||||
}
|
||||
|
||||
function passwordReset() {
|
||||
var xhr = postAjax('/api/v1/passwordreset', {
|
||||
password: document.getElementById('password_input').value,
|
||||
password_confirm: document.getElementById('password_confirm').value
|
||||
});
|
||||
xhr.onload = function () {
|
||||
if (xhr.responseText.charAt(0) !== "{") {
|
||||
return showErrorPopup('Whoops, something went wrong. Try again later.');
|
||||
}
|
||||
response = JSON.parse(xhr.responseText);
|
||||
if (response.success === true) {
|
||||
location.pathname = '/pnid/login';
|
||||
} else if (response.errors) {
|
||||
showErrorPopup(response.errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function register() {
|
||||
var xhr = postAjax('/api/v1/register', {
|
||||
email: document.getElementById('email_input').value,
|
||||
|
||||
@@ -68,6 +68,15 @@
|
||||
"link_text": "Click here to login."
|
||||
}
|
||||
},
|
||||
"password": {
|
||||
"card": {
|
||||
"caption": "Forgot password?",
|
||||
"title": "Reset password",
|
||||
"password_text": "New password",
|
||||
"password_confirm_text": "Confirm password",
|
||||
"button_text": "Reset password"
|
||||
}
|
||||
},
|
||||
"about": {
|
||||
"caption": "What is this?",
|
||||
"title": "About",
|
||||
|
||||
@@ -41,6 +41,17 @@ router.get('/pnid/login', (request, response) => {
|
||||
locale: utilHelper.getLocale('US', 'en')
|
||||
});
|
||||
});
|
||||
// renders password reset page
|
||||
router.get('/pnid/passwordreset', (request, response) => {
|
||||
return response.render('password', {
|
||||
title: 'Pretendo | Password reset',
|
||||
description: 'On the Pretendo Network ID Dashboard you can manage your personal information and make new virtual consoles to use for login on your home console.',
|
||||
url: request.protocol + '://' + request.get('host') + request.originalUrl,
|
||||
baseurl: request.protocol + '://' + request.get('host'),
|
||||
locale: utilHelper.getLocale('US', 'en'),
|
||||
user: utilHelper.templateReadyUser(request)
|
||||
});
|
||||
});
|
||||
// logout
|
||||
router.get('/pnid/logout', userMiddleware.pnidAuthNeeded, (request, response) => {
|
||||
request.logout();
|
||||
@@ -85,6 +96,26 @@ router.post('/api/v1/login', passport.authenticate('PNIDStrategy'), function (re
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
* /api/v1/passwordreset
|
||||
*
|
||||
* signs user in
|
||||
*
|
||||
* post {
|
||||
* password
|
||||
* password_confirm
|
||||
* }
|
||||
* return {
|
||||
* code: http code
|
||||
* success: boolean
|
||||
* errors: Strings[messages]
|
||||
* }
|
||||
*/
|
||||
router.post('/api/v1/passwordreset', function (request, response) {
|
||||
//TODO make the actual password change
|
||||
return apiHelper.sendReturn(response, {});
|
||||
});
|
||||
|
||||
/*
|
||||
* /api/v1/register
|
||||
*
|
||||
|
||||
30
views/password.hbs
Normal file
30
views/password.hbs
Normal file
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{{> metatags }}
|
||||
<title>{{ title }}</title>
|
||||
<!-- css files -->
|
||||
<link rel="stylesheet" href="/assets/css/pretendo-common.css">
|
||||
<!-- page specific -->
|
||||
<link rel="stylesheet" href="/assets/css/pretendo-auth.css">
|
||||
<script src="/assets/js/api.js" defer></script>
|
||||
</head>
|
||||
<body class="flex center">
|
||||
<div class="card">
|
||||
<h2 class="head">{{ locale.nav.brand }}</h2>
|
||||
<div class="content">
|
||||
<p class="txt-highlight">{{ locale.password.card.caption }}</p>
|
||||
<h1 class="txt-title small">{{ locale.password.card.title }}</h1>
|
||||
<div id="errorBox" class="error hide"></div>
|
||||
<form method="POST">
|
||||
<label for="password_input">{{ locale.password.card.password_text}}</label>
|
||||
<input type="password" class="hasLabel" id="password_input" name="password_input">
|
||||
<label for="password_confirm">{{ locale.password.card.password_confirm_text }}</label>
|
||||
<input type="password" class="hasLabel" id="password_confirm" name="password_confirm">
|
||||
</form>
|
||||
<button class="btn btnMargin" onclick="passwordReset();">{{ locale.password.card.button_text }}</button>
|
||||
</div>
|
||||
</div>
|
||||
{{> footer-default }}
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user