LoginAction.js
Summary
Contains LoginAction class.
This is part of Troika.ASP Framework - web development MVC framework for ASP 3.0.
Please visit www.troika-asp.com for more details.
Version: $Revision: 1.3 $
Author: Pavel Chuchev pav@troika-asp.com
|
Class Summary
|
| LoginAction |
This is HelloAction class command implementation. |
LoginAction.prototype = new Command();
LoginAction.prototype.constructor = LoginAction;
LoginAction.prototype.init = function (config) {
Command.prototype.init.call(this, config);
return this;
};
function LoginAction(config) {
if (arguments.length) {
this.init(config);
}
this.execute = function (environment, loginForm) {
var result = new ResponseContext();
if (environment.request.get("submit")) {
var errors = loginForm.validate();
if (errors.size()) {
result.errors.addAll(errors);
result.forward = this.findForward(loginForm, "login-form");
}
else {
var dao = new LoginDAO(this.getConnectionString("helloworld-db"));
var vo = dao.findByUsernameAndPassword(loginForm.userName, loginForm.password);
if (vo) {
environment.session.put("security.role", vo.securityRole);
environment.session.put("loginId", vo.loginId);
environment.session.put("memberId", vo.memberId);
result.forward = this.getNextPageForward(environment, loginForm, vo);
}
else {
this.error("Could not log you in please try again.", loginForm, result, environment);
}
}
}
else {
result.forward = this.findForward(loginForm, "login-form");
}
return result;
};
this.getNextPageForward = function (environment, loginForm, userVO) {
var session = environment.session;
var nextPage = session.get("nextPageForward");
var result = undefined;
if (nextPage) {
session.remove("nextPageForward");
result = new Forward(true, nextPage);
}
else {
result = this.findForward(loginForm, "success");
}
return result;
};
this.error = function (msg, loginForm, responseCxt) {
responseCxt.errors.add(new Error(msg));
responseCxt.forward = this.findForward(loginForm, "login-form");
};
}
www.troika-asp.com
Documentation generated on Sun Jun 15 17:59:32 2008