package com.my.lock;

import net.sourceforge.stripes.action.ActionBeanContext;
import com.my.lock.Person;

/**
 * ActionBeanContext subclass for the Bugzooky application that manages where
 * values like the logged in user are stored.
 * 
 * @author Tim Fennell
 */
public class MyActionBeanContext extends ActionBeanContext
{

	/** Gets the currently logged in user, or null if no-one is logged in. */
	public Person getUser()
	{
		return (Person) getRequest().getSession().getAttribute("user");
	}

	/** Sets the currently logged in user. */
	public void setUser(Person currentUser)
	{
		getRequest().getSession().setAttribute("user", currentUser);
	}

	/** Logs the user out by invalidating the session. */
	public void logout()
	{
		getRequest().getSession().invalidate();
	}
}
