Warning: Attempt to read property "date" on null in /home/www/websvn.26th.net/html/blame.php on line 247

Warning: Attempt to read property "msg" on null in /home/www/websvn.26th.net/html/blame.php on line 247

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/www/websvn.26th.net/html/blame.php on line 247

Warning: Attempt to read property "date" on null in /home/www/websvn.26th.net/html/blame.php on line 247

Warning: Attempt to read property "msg" on null in /home/www/websvn.26th.net/html/blame.php on line 247

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/www/websvn.26th.net/html/blame.php on line 247

Warning: Attempt to read property "date" on null in /home/www/websvn.26th.net/html/blame.php on line 247

Warning: Attempt to read property "msg" on null in /home/www/websvn.26th.net/html/blame.php on line 247

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/www/websvn.26th.net/html/blame.php on line 247

Warning: Attempt to read property "date" on null in /home/www/websvn.26th.net/html/blame.php on line 247

Warning: Attempt to read property "msg" on null in /home/www/websvn.26th.net/html/blame.php on line 247

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/www/websvn.26th.net/html/blame.php on line 247
WebSVN – general – Blame – /hostadmiral/trunk/src/ak/hostadmiral/core/action/LoginAction.java/ – Rev 950

Subversion Repositories general

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
924 dev 1
package ak.hostadmiral.core.action;
919 dev 2
 
3
import javax.servlet.http.HttpServletRequest;
4
import javax.servlet.http.HttpServletResponse;
5
 
950 dev 6
import org.apache.struts.Globals;
919 dev 7
import org.apache.struts.action.Action;
8
import org.apache.struts.action.ActionMapping;
9
import org.apache.struts.action.ActionForm;
10
import org.apache.struts.action.DynaActionForm;
11
import org.apache.struts.action.ActionForward;
12
import org.apache.struts.action.ActionMessages;
13
import org.apache.struts.action.ActionErrors;
14
import org.apache.struts.action.ActionError;
15
 
16
import ak.backpath.BackPath;
17
 
924 dev 18
import ak.hostadmiral.core.CoreResources;
19
import ak.hostadmiral.core.model.User;
20
import ak.hostadmiral.core.model.UserManager;
919 dev 21
 
22
public final class LoginAction
23
	extends Action
24
{
25
	public ActionForward execute(ActionMapping mapping, ActionForm form,
26
			HttpServletRequest request, HttpServletResponse response)
27
		throws Exception
28
	{
29
		DynaActionForm theForm = (DynaActionForm)form;
30
 
31
		User user = UserManager.getInstance().loginUser(
949 dev 32
			(String)theForm.get("login"), (String)theForm.get("password"), request.getRemoteAddr());
919 dev 33
 
34
		if(user == null) {
35
			ActionErrors errors = new ActionErrors();
36
			errors.add(ActionMessages.GLOBAL_MESSAGE,
37
				new ActionError(CoreResources.LOGIN_FAILED));
38
			saveErrors(request, errors);
39
			return mapping.getInputForward();
40
		}
41
	    else {
42
	    	request.getSession().setAttribute("user", user);
950 dev 43
	    	request.getSession().setAttribute(Globals.LOCALE_KEY, user.getLocale());
919 dev 44
 
45
	    	String origin = BackPath.findBackPath(request).getBackwardUrl();
46
	    	if(origin == null || origin.length() <= 0) {
47
				return mapping.findForward("default");
48
			}
49
			else {
50
				response.sendRedirect(origin);
51
				return null;
52
			}
53
		}
54
	}
55
}