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.app.web.base.login.LocalUserCredential;
20 import org.codelibs.fess.util.RenderDataUtil;
21 import org.dbflute.optional.OptionalThing;
22 import org.lastaflute.web.Execute;
23 import org.lastaflute.web.login.exception.LoginFailureException;
24 import org.lastaflute.web.response.HtmlResponse;
25
26 public class LoginAction extends FessLoginAction {
27
28
29
30
31
32 @Execute
33 public HtmlResponse index() {
34 return asIndexPage(null).useForm(LoginForm.class);
35 }
36
37 private HtmlResponse asIndexPage(final LoginForm form) {
38 if (form != null) {
39 form.clearSecurityInfo();
40 }
41 return asHtml(virtualHost(path_Login_IndexJsp)).renderWith(data -> {
42 RenderDataUtil.register(data, "notification", fessConfig.getNotificationLogin());
43 saveToken();
44 });
45 }
46
47 @Execute
48 public HtmlResponse login(final LoginForm form) {
49 validate(form, messages -> {}, () -> asIndexPage(form));
50 verifyToken(() -> asIndexPage(form));
51 final String username = form.username;
52 final String password = form.password;
53 form.clearSecurityInfo();
54 try {
55 return fessLoginAssist.loginRedirect(new LocalUserCredential(username, password), op -> {}, () -> {
56 activityHelper.login(getUserBean());
57 userInfoHelper.deleteUserCodeFromCookie(request);
58 return getHtmlResponse();
59 });
60 } catch (final LoginFailureException lfe) {
61 activityHelper.loginFailure(OptionalThing.of(new LocalUserCredential(username, password)));
62 throwValidationError(messages -> messages.addErrorsLoginError(GLOBAL), () -> asIndexPage(form));
63 }
64 return redirect(getClass());
65 }
66
67 }