2013-09-03 09:59:30 +00:00
/ * *
2014-01-22 10:12:51 +00:00
* @ name Password Module
* @ description Controls the access to password - protected albums and photos .
2013-09-03 09:59:30 +00:00
* @ author Tobias Reich
2014-01-22 10:12:51 +00:00
* @ copyright 2014 by Tobias Reich
2013-09-03 09:59:30 +00:00
* /
password = {
value : "" ,
get : function ( albumID , callback ) {
2014-01-22 10:12:51 +00:00
var passwd = $ ( ".message input.text" ) . val ( ) ,
2013-09-03 09:59:30 +00:00
params ;
if ( ! lychee . publicMode ) callback ( ) ;
else if ( album . json && album . json . password == false ) callback ( ) ;
else if ( albums . json && albums . json . content [ albumID ] . password == false ) callback ( ) ;
else if ( ! albums . json && ! album . json ) {
// Continue without password
album . json = { password : true } ;
callback ( "" ) ;
} else if ( passwd == undefined ) {
// Request password
password . getDialog ( albumID , callback ) ;
} else {
// Check password
2014-04-01 19:33:29 +00:00
params = "checkAlbumAccess&albumID=" + albumID + "&password=" + md5 ( passwd ) ;
2014-01-22 10:12:51 +00:00
lychee . api ( params , function ( data ) {
2013-09-03 09:59:30 +00:00
2014-01-22 10:12:51 +00:00
if ( data === true ) {
2014-04-01 19:33:29 +00:00
password . value = md5 ( passwd ) ;
2013-09-03 09:59:30 +00:00
callback ( ) ;
} else {
lychee . goto ( "" ) ;
2014-01-22 10:12:51 +00:00
loadingBar . show ( "error" , "Access denied. Wrong password!" ) ;
2013-09-03 09:59:30 +00:00
}
} ) ;
}
} ,
getDialog : function ( albumID , callback ) {
var buttons ;
buttons = [
[ "Enter" , function ( ) { password . get ( albumID , callback ) } ] ,
[ "Cancel" , lychee . goto ]
] ;
2014-01-22 10:12:51 +00:00
modal . show ( "<a class='icon-lock'></a> Enter Password" , "This album is protected by a password. Enter the password below to view the photos of this album: <input class='text' type='password' placeholder='password' value=''>" , buttons , - 110 , false ) ;
2013-09-03 09:59:30 +00:00
}
2014-02-25 22:37:05 +00:00
} ;