1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.codelibs.fess.app.web.login;
17
18 import org.codelibs.fess.app.web.base.FessLoginAction;
19 import org.codelibs.fess.util.RenderDataUtil;
20 import org.lastaflute.web.Execute;
21 import org.lastaflute.web.login.credential.UserPasswordCredential;
22 import org.lastaflute.web.login.exception.LoginFailureException;
23 import org.lastaflute.web.response.HtmlResponse;
24
25 public class LoginAction extends FessLoginAction {
26
27
28
29
30
31 @Execute
32 public HtmlResponse index() {
33 return asIndexPage(null).useForm(LoginForm.class);
34 }
35
36 private HtmlResponse asIndexPage(final LoginForm form) {
37 if (form != null) {
38 form.clearSecurityInfo();
39 }
40 return asHtml(virtualHost(path_Login_IndexJsp)).renderWith(data -> {
41 RenderDataUtil.register(data, "notification", fessConfig.getNotificationLogin());
42 saveToken();
43 });
44 }
45
46 @Execute
47 public HtmlResponse login(final LoginForm form) {
48 validate(form, messages -> {}, () -> asIndexPage(form));
49 verifyToken(() -> asIndexPage(form));
50 final String username = form.username;
51 final String password = form.password;
52 form.clearSecurityInfo();
53 try {
54 return fessLoginAssist.loginRedirect(new UserPasswordCredential(username, password), op -> {}, () -> {
55 activityHelper.login(getUserBean());
56 userInfoHelper.deleteUserCodeFromCookie(request);
57 return getHtmlResponse();
58 });
59 } catch (final LoginFailureException lfe) {
60 throwValidationError(messages -> messages.addErrorsLoginError(GLOBAL), () -> asIndexPage(form));
61 }
62 return redirect(getClass());
63 }
64
65 }