Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Creative commons Attribution-NonCommercial license. http://creativecommons.org/licenses/by-nc/2.5/au/deed.en_GB NO WARRANTY IS GIVEN OR IMPLIED, USE AT YOUR OWN RISK.
 
 package base.jee.servlet;
 
public class ActivateAccountServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private JeeBase jee;
	public ActivateAccountServlet(JeeBase jeethrows IOException {
		this. = jee;
		if(jee.getSettings().get("support_team.email"null) == null) {
			jee.getSettings().set("support_team.email""support@example.com");
		}
		if(jee.getSettings().get("support_team.name"null) == null) {
			jee.getSettings().set("support_team.name""Support Team");
		}
	}

	protected void doGet(HttpServletRequest requestHttpServletResponse responsethrows ServletExceptionIOException {
		response.setContentType("text/html; charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		String ip = BaseServlet.getIp(request);
		String token = request.getParameter("token");
		String newPassword = request.getParameter("new_password");
		String newPassword2 = request.getParameter("new_password2");
		if(token == null) { token = ""; }
		if(newPassword == null) { newPassword = ""; }
		if(newPassword2 == null) { newPassword2 = ""; }
		if(newPassword.length() > 0) {
			try {
				.getAPI().activateAccountUsingToken(tokennewPasswordnewPassword2ip);
				response.setHeader("Location".getSettings().get("base.url""") + "/signin?activated=activated");
				response.setStatus(302);
				return;
				ST page = .getPage(new User(.getAPI().getUnauthenticatedRolesCache(), ip), "activate_account");
				page.remove("shortcuts"); // Don't need shortcuts on this page
				page.add("error"e.getMessage());
				page.add("token"token);
				page.add("ldap_enabled".getSettings().get("ldap.enabled""true").equalsIgnoreCase("true"));
				page.add("breadcrumbs"new Breadcrumb("Reset your password"null));
				response.getWriter().write(page.render());
			}
else {
			ST page = .getPage(new User(.getAPI().getUnauthenticatedRolesCache(), ip), "activate_account");
			page.remove("shortcuts"); // Don't need shortcuts on this page
			page.add("token"token);
			page.add("ldap_enabled".getSettings().get("ldap.enabled""true").equalsIgnoreCase("true"));
			page.add("breadcrumbs"new Breadcrumb("Reset your password"null));
			response.getWriter().write(page.render());
		}
	}
	protected void doPost(HttpServletRequest requestHttpServletResponse responsethrows ServletExceptionIOException {
		doGet(requestresponse);
	}
New to GrepCode? Check out our FAQ X