mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-14 16:36:21 +00:00
Added changePassword
This commit is contained in:
parent
0540b0775d
commit
ec9de34cb3
@ -53,7 +53,8 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<p class="menu-label">Administration</p>
|
<p class="menu-label">Administration</p>
|
||||||
<ul class="menu-list">
|
<ul class="menu-list">
|
||||||
<li><a id="itemTokens" onclick="panel.changeTokens()">Change your token</a></li>
|
<li><a id="itemTokens" onclick="panel.changeToken()">Change your token</a></li>
|
||||||
|
<li><a id="itemTokens" onclick="panel.changePassword()">Change your password</a></li>
|
||||||
<li><a onclick="panel.logout()">Logout</a></li>
|
<li><a onclick="panel.logout()">Logout</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</aside>
|
</aside>
|
||||||
|
@ -463,7 +463,7 @@ panel.getAlbum = function(item){
|
|||||||
panel.getUploads(item.id);
|
panel.getUploads(item.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
panel.changeTokens = function(){
|
panel.changeToken = function(){
|
||||||
|
|
||||||
axios.get('/api/tokens')
|
axios.get('/api/tokens')
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
@ -526,6 +526,55 @@ panel.getNewToken = function(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
panel.changePassword = function(){
|
||||||
|
|
||||||
|
panel.page.innerHTML = '';
|
||||||
|
var container = document.createElement('div');
|
||||||
|
container.className = "container";
|
||||||
|
container.innerHTML = `
|
||||||
|
<h2 class="subtitle">Change your password</h2>
|
||||||
|
|
||||||
|
<label class="label">New password:</label>
|
||||||
|
<p class="control has-addons">
|
||||||
|
<input id="password" class="input is-expanded" type="password" placeholder="Your new password">
|
||||||
|
<a id="sendChangePassword" class="button is-primary">Set new password</a>
|
||||||
|
</p>
|
||||||
|
`;
|
||||||
|
|
||||||
|
panel.page.appendChild(container);
|
||||||
|
|
||||||
|
document.getElementById('sendChangePassword').addEventListener('click', function(){
|
||||||
|
panel.sendNewPassword();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
panel.sendNewPassword = function(){
|
||||||
|
|
||||||
|
axios.post('/api/password/change')
|
||||||
|
.then(function (response) {
|
||||||
|
|
||||||
|
if(response.data.success === false){
|
||||||
|
if(response.data.description === 'No token provided') return panel.verifyToken(panel.token);
|
||||||
|
else return swal("An error ocurred", response.data.description, "error");
|
||||||
|
}
|
||||||
|
|
||||||
|
swal({
|
||||||
|
title: "Woohoo!",
|
||||||
|
text: 'Your password was changed successfully.',
|
||||||
|
type: "success"
|
||||||
|
}, function(){
|
||||||
|
location.reload();
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
return swal("An error ocurred", 'There was an error with the request, please check the console for more information.', "error");
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
panel.setActiveMenu = function(item){
|
panel.setActiveMenu = function(item){
|
||||||
var menu = document.getElementById('menu');
|
var menu = document.getElementById('menu');
|
||||||
var items = menu.getElementsByTagName('a');
|
var items = menu.getElementsByTagName('a');
|
||||||
|
@ -14,6 +14,7 @@ routes.get ('/check', (req, res, next) => {
|
|||||||
|
|
||||||
routes.post ('/login', (req, res, next) => authController.verify(req, res, next))
|
routes.post ('/login', (req, res, next) => authController.verify(req, res, next))
|
||||||
routes.post ('/register', (req, res, next) => authController.register(req, res, next))
|
routes.post ('/register', (req, res, next) => authController.register(req, res, next))
|
||||||
|
routes.post ('/password/change', (req, res, next) => authController.changePassword(req, res, next))
|
||||||
|
|
||||||
routes.get ('/uploads', (req, res, next) => uploadController.list(req, res))
|
routes.get ('/uploads', (req, res, next) => uploadController.list(req, res))
|
||||||
routes.get ('/uploads/:page', (req, res, next) => uploadController.list(req, res))
|
routes.get ('/uploads/:page', (req, res, next) => uploadController.list(req, res))
|
||||||
|
Loading…
Reference in New Issue
Block a user