Updated password.js (ES2015)
This commit is contained in:
parent
710aa2bf52
commit
9e976b1856
BIN
dist/main.js
vendored
BIN
dist/main.js
vendored
Binary file not shown.
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @description Controls the access to password-protected albums and photos.
|
* @description Controls the access to password-protected albums and photos.
|
||||||
* @copyright 2015 by Tobias Reich
|
* @copyright 2015 by Tobias Reich
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -11,27 +11,25 @@ password = {
|
|||||||
|
|
||||||
password.get = function(albumID, callback, passwd) {
|
password.get = function(albumID, callback, passwd) {
|
||||||
|
|
||||||
var params;
|
if (lychee.publicMode===false) callback()
|
||||||
|
else if (album.json && album.json.password==='0') callback()
|
||||||
if (lychee.publicMode===false) callback();
|
else if (albums.json && albums.getByID(albumID).password==='0') callback()
|
||||||
else if (album.json&&album.json.password==='0') callback();
|
else if (!albums.json && !album.json) {
|
||||||
else if (albums.json&&albums.getByID(albumID).password==='0') callback();
|
|
||||||
else if (!albums.json&&!album.json) {
|
|
||||||
|
|
||||||
// Continue without password
|
// Continue without password
|
||||||
album.json = {password: true};
|
album.json = { password: true }
|
||||||
callback('');
|
callback('')
|
||||||
|
|
||||||
} else if (passwd==null) {
|
} else if (passwd==null) {
|
||||||
|
|
||||||
// Request password
|
// Request password
|
||||||
password.getDialog(albumID, callback);
|
password.getDialog(albumID, callback)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Check password
|
// Check password
|
||||||
|
|
||||||
params = {
|
let params = {
|
||||||
albumID,
|
albumID,
|
||||||
password: passwd
|
password: passwd
|
||||||
}
|
}
|
||||||
@ -39,14 +37,14 @@ password.get = function(albumID, callback, passwd) {
|
|||||||
api.post('Album::getPublic', params, function(data) {
|
api.post('Album::getPublic', params, function(data) {
|
||||||
|
|
||||||
if (data===true) {
|
if (data===true) {
|
||||||
basicModal.close();
|
basicModal.close()
|
||||||
password.value = passwd;
|
password.value = passwd
|
||||||
callback();
|
callback()
|
||||||
} else {
|
} else {
|
||||||
basicModal.error('password');
|
basicModal.error('password')
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,23 +52,19 @@ password.get = function(albumID, callback, passwd) {
|
|||||||
|
|
||||||
password.getDialog = function(albumID, callback) {
|
password.getDialog = function(albumID, callback) {
|
||||||
|
|
||||||
var action,
|
const action = (data) => password.get(albumID, callback, data.password)
|
||||||
cancel,
|
|
||||||
msg = '';
|
|
||||||
|
|
||||||
action = function(data) { password.get(albumID, callback, data.password) }
|
const cancel = () => {
|
||||||
|
basicModal.close()
|
||||||
cancel = function() {
|
if (visible.albums()===false) lychee.goto()
|
||||||
basicModal.close();
|
|
||||||
if (visible.albums()===false) lychee.goto();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = `
|
let msg = `
|
||||||
<p>
|
<p>
|
||||||
This album is protected by a password. Enter the password below to view the photos of this album:
|
This album is protected by a password. Enter the password below to view the photos of this album:
|
||||||
<input name='password' class='text' type='password' placeholder='password' value=''>
|
<input name='password' class='text' type='password' placeholder='password' value=''>
|
||||||
</p>
|
</p>
|
||||||
`
|
`
|
||||||
|
|
||||||
basicModal.show({
|
basicModal.show({
|
||||||
body: msg,
|
body: msg,
|
||||||
@ -84,6 +78,6 @@ password.getDialog = function(albumID, callback) {
|
|||||||
fn: cancel
|
fn: cancel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user