Skip to content

Instantly share code, notes, and snippets.

@raj-rajaratnam
Created April 24, 2014 17:43
Show Gist options
  • Save raj-rajaratnam/11263172 to your computer and use it in GitHub Desktop.
Save raj-rajaratnam/11263172 to your computer and use it in GitHub Desktop.
<%
application.put('account',
{
'admin' : {
'name':'Rajkumar',
'accountNumber':'8008006514',
'accountType':'Saving',
'balance':'LKR 28,256.00',
'hold':'LKR 0.00'
},
'samisa' : {
'name':'Samisa',
'accountNumber':'8708105469',
'accountType':'Saving',
'balance':'LKR 89565228,256.00',
'hold':'LKR 5650.00'
}
}
);
application.put('user',
{
'admin' : {
'username':'admin',
'password' : 'admin'
},
'samisa' : {
'username':'samisa',
'password' : 'samisa'
}
}
);
application.put('history',
{
'admin' : {
'protocol' : 'HTTP/1.1' ,
'userAgent' : 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:28.0) Gecko/20100101 Firefox/28.0' ,
'securedConnection' : 'false' ,
'clientIP' : '10.100.5.84' ,
'loggedInTime' : 'Thu Apr 24 2014 14:06'
},
'samisa' : {
'protocol' : 'HTTP/1.1' ,
'userAgent' : 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:28.0) Gecko/20100101 Firefox/28.0' ,
'securedConnection' : 'true' ,
'clientIP' : '10.89.5.154' ,
'loggedInTime' : 'Wed Apr 23 2014 9:06'
}
}
);
if (request.getParameter("action") == "login") {
var username = decodeURI(request.getParameter("username"));
var password = decodeURI(request.getParameter("password"));
var loginTime = request.getParameter("time");
if(application.get('user')[username] != null && application.get('user')[username].password == password){
var info = {
'loginTime' : loginTime,
'username' : username,
'password' : password,
};
session.put("info",info);
}
else {
var loginFailed = {
'failed' : 'true'
};
session.put("loginFailed",loginFailed);
}
} else if (request.getParameter("action")== "logout") {
session.invalidate();
}
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment