Skip to content

Instantly share code, notes, and snippets.

@pvlasov
Created March 29, 2017 02:48
Show Gist options
  • Save pvlasov/567540e998226b0ffce6543700fdafe7 to your computer and use it in GitHub Desktop.
Save pvlasov/567540e998226b0ffce6543700fdafe7 to your computer and use it in GitHub Desktop.
Guest getIndexHtml() method processing login
@RouteMethod(
path="index.html",
value = { RequestMethod.GET, RequestMethod.POST },
lock = @RouteMethod.Lock(type = Type.READ, path = ".."),
comment="Renders login form on GET, processes it on POST")
public Object indexHtml(
@ContextParameter CDOTransactionHttpServletRequestContext<LoginPasswordCredentials> context,
@TargetParameter Guest target,
@QueryParameter("url") String returnURL,
@QueryParameter("login") String login,
@QueryParameter("password") String password) throws Exception {
Form loginForm = processLogin(context, returnURL, login, password);
if (loginForm == null) {
return Action.NOP;
}
loginForm
.action("index.html")
.method(Method.post)
.bootstrap().grid().col(Bootstrap.DeviceSize.EXTRA_SMALL, 12)
.bootstrap().grid().col(Bootstrap.DeviceSize.SMALL, 12)
.bootstrap().grid().col(Bootstrap.DeviceSize.MEDIUM, 9)
.bootstrap().grid().col(Bootstrap.DeviceSize.LARGE, 7);
HTMLFactory htmlFactory = getHTMLFactory(context);
Fragment content = htmlFactory.fragment();
content.content(content.getFactory().tag(TagName.h3, getResourceString(context, "logIn")));
content.content(loginForm);
return renderPage(context, target, getResourceString(context, "logIn"), content, env -> env.remove(PageTemplateTokens.LEFT_PANEL.literal));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment