Merge pull request #363 from kw-udon/10.0.x-dev

Transition to profile page
This commit is contained in:
Shinsuke Sugaya 2016-02-16 21:54:39 +09:00
commit 74613166da
13 changed files with 320 additions and 3 deletions

View file

@ -0,0 +1,94 @@
/*
* Copyright 2012-2016 CodeLibs Project and the Others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
/**
* @author Keiichi Watanabe
*/
package org.codelibs.fess.app.web.profile;
import javax.annotation.Resource;
import org.codelibs.core.lang.StringUtil;
import org.codelibs.fess.app.web.base.FessSearchAction;
import org.codelibs.fess.app.web.base.login.FessLoginAssist;
import org.codelibs.fess.app.web.login.LoginAction;
import org.lastaflute.web.Execute;
import org.lastaflute.web.response.HtmlResponse;
import org.lastaflute.web.validation.VaErrorHook;
public class ProfileAction extends FessSearchAction {
// ===================================================================================
// Constant
//
// ===================================================================================
// Attribute
//
@Resource
protected FessLoginAssist fessLoginAssist;
// ===================================================================================
// Hook
// ======
// ===================================================================================
// Search Execute
// ==============
@Execute
public HtmlResponse index() {
if (fessLoginAssist.getSessionUserBean().isPresent()) {
return asHtml(path_Profile_IndexJsp).useForm(ProfileForm.class);
} else {
return redirect(LoginAction.class);
}
}
@Execute
public HtmlResponse changePassword(final ProfileForm form) {
validatePasswordForm(form, () -> index());
// TODO
return redirect(getClass());
}
private void validatePasswordForm(final ProfileForm form, final VaErrorHook validationErrorLambda) {
validate(form, messages -> {}, () -> {
form.clearSecurityInfo();
return index();
});
if (StringUtil.isBlank(form.oldPassword)) {
form.clearSecurityInfo();
throwValidationError(messages -> {
messages.addErrorsBlankPassword("oldPassword");
}, validationErrorLambda);
}
if (StringUtil.isBlank(form.newPassword)) {
form.newPassword = null;
form.confirmPassword = null;
throwValidationError(messages -> {
messages.addErrorsBlankPassword("newPassword");
}, validationErrorLambda);
}
if (form.newPassword != null && !form.newPassword.equals(form.confirmPassword)) {
form.newPassword = null;
form.confirmPassword = null;
throwValidationError(messages -> {
messages.addErrorsInvalidConfirmPassword("confirmPassword");
}, validationErrorLambda);
}
}
}

View file

@ -0,0 +1,44 @@
/*
* Copyright 2012-2016 CodeLibs Project and the Others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
/**
* @author Keiichi Watanabe
*/
package org.codelibs.fess.app.web.profile;
import java.io.Serializable;
import org.hibernate.validator.constraints.NotBlank;
public class ProfileForm implements Serializable {
private static final long serialVersionUID = 1L;
@NotBlank
public String oldPassword;
@NotBlank
public String newPassword;
@NotBlank
public String confirmPassword;
public void clearSecurityInfo() {
oldPassword = null;
newPassword = null;
confirmPassword = null;
}
}

View file

@ -329,6 +329,15 @@ public interface FessHtmlPath {
/** The path of the HTML: /login/logout.jsp */
HtmlNext path_Login_LogoutJsp = new HtmlNext("/login/logout.jsp");
/** The path of the HTML: /profile/footer.jsp */
HtmlNext path_Profile_FooterJsp = new HtmlNext("/profile/footer.jsp");
/** The path of the HTML: /profile/header.jsp */
HtmlNext path_Profile_HeaderJsp = new HtmlNext("/profile/header.jsp");
/** The path of the HTML: /profile/index.jsp */
HtmlNext path_Profile_IndexJsp = new HtmlNext("/profile/index.jsp");
/** The path of the HTML: /search.jsp */
HtmlNext path_SearchJsp = new HtmlNext("/search.jsp");

View file

@ -770,6 +770,27 @@ public class FessLabels extends ActionMessages {
/** The key of the message: Logout */
public static final String LABELS_logout_button = "{labels.logout_button}";
/** The key of the message: Profile */
public static final String LABELS_PROFILE = "{labels.profile}";
/** The key of the message: Profile */
public static final String LABELS_profile_button = "{labels.profile_button}";
/** The key of the message: Profile */
public static final String LABELS_PROFILE_TITLE = "{labels.profile.title}";
/** The key of the message: Update */
public static final String LABELS_PROFILE_UPDATE = "{labels.profile.update}";
/** The key of the message: Old Password */
public static final String LABELS_PROFILE_placeholder_old_password = "{labels.profile.placeholder_old_password}";
/** The key of the message: New Password */
public static final String LABELS_PROFILE_placeholder_new_password = "{labels.profile.placeholder_new_password}";
/** The key of the message: Confirm New Password */
public static final String LABELS_PROFILE_placeholder_confirm_new_password = "{labels.profile.placeholder_confirm_new_password}";
/** The key of the message: Search */
public static final String LABELS_TOP_SEARCH = "{labels.top.search}";

View file

@ -614,7 +614,7 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
/** The key of the configuration. e.g. guest */
String SUGGEST_ROLE_FILTERS = "suggest.role.filters";
/** The key of the configuration. e.g. true */
/** The key of the configuration. e.g. false */
String LDAP_ADMIN_ENABLED = "ldap.admin.enabled";
/** The key of the configuration. e.g. com.sun.jndi.ldap.LdapCtxFactory */
@ -2495,7 +2495,7 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
/**
* Get the value for the key 'ldap.admin.enabled'. <br>
* The value is, e.g. true <br>
* The value is, e.g. false <br>
* comment: ------
* @return The value of found property. (NotNull: if not found, exception but basically no way)
*/
@ -2503,7 +2503,7 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
/**
* Is the property for the key 'ldap.admin.enabled' true? <br>
* The value is, e.g. true <br>
* The value is, e.g. false <br>
* comment: ------
* @return The determination, true or false. (if not found, exception but basically no way)
*/

View file

@ -251,6 +251,13 @@ labels.logout_title=Logout
labels.logout=Logout
labels.do_you_want_to_logout=Do you want to logout?
labels.logout_button=Logout
labels.profile=Profile
labels.profile_button=Profile
labels.profile.title=Profile
labels.profile.update=Update
labels.profile.placeholder_old_password=Old Password
labels.profile.placeholder_new_password=New Password
labels.profile.placeholder_confirm_new_password=Confirm New Password
labels.top.search=Search
labels.index_title=Fess
labels.index_form_search_btn=Search

View file

@ -251,6 +251,13 @@ labels.logout_title=Logout
labels.logout=Logout
labels.do_you_want_to_logout=Do you want to logout?
labels.logout_button=Logout
labels.profile=Profile
labels.profile_button=Profile
labels.profile.title=Profile
labels.profile.update=Update
labels.profile.placeholder_old_password=Old Password
labels.profile.placeholder_new_password=New Password
labels.profile.placeholder_confirm_new_password=Confirm New Password
labels.top.search=Search
labels.index_title=Fess
labels.index_form_search_btn=Search

View file

@ -245,6 +245,13 @@ labels.logout_title = \u30ed\u30b0\u30a2\u30a6\u30c8
labels.logout = \u30ed\u30b0\u30a2\u30a6\u30c8
labels.do_you_want_to_logout = \u30ed\u30b0\u30a2\u30a6\u30c8\u3057\u307e\u3059\u304b\uff1f
labels.logout_button = \u30ed\u30b0\u30a2\u30a6\u30c8
labels.profile = \u8a2d\u5b9a
labels.profile_button = \u8a2d\u5b9a
labels.profile.title= \u8a2d\u5b9a
labels.profile.update= \u66f4\u65b0
labels.profile.placeholder_old_password= \u53e4\u3044\u30d1\u30b9\u30ef\u30fc\u30c9
labels.profile.placeholder_new_password= \u65b0\u3057\u3044\u30d1\u30b9\u30ef\u30fc\u30c9
labels.profile.placeholder_confirm_new_password= \u65b0\u3057\u3044\u30d1\u30b9\u30ef\u30fc\u30c9\x28\u78ba\u8a8d\x29
labels.top.search = \u691c\u7d22
labels.index_title = Fess
labels.index_form_search_btn = \u691c\u7d22

View file

@ -15,6 +15,9 @@ ${fe:facetForm()}${fe:geoForm()}
<i class="fa fa-user"></i>${username}
</a>
<div class="dropdown-menu" aria-labelledby="userMenu">
<la:link href="/profile" styleClass="dropdown-item">
<la:message key="labels.profile" />
</la:link>
<la:link href="/logout" styleClass="dropdown-item">
<la:message key="labels.logout" />
</la:link>

View file

@ -29,6 +29,9 @@
aria-expanded="false"> <i class="fa fa-user"></i>${username}
</a>
<div class="dropdown-menu" aria-labelledby="userMenu">
<la:link href="/profile" styleClass="dropdown-item">
<la:message key="labels.profile" />
</la:link>
<la:link href="/logout" styleClass="dropdown-item">
<la:message key="labels.logout" />
</la:link>

View file

@ -0,0 +1,8 @@
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<footer class="footer bd-footer text-muted" role="contentinfo">
<div class="container center">
<p class="text-muted">
<la:message key="labels.footer.copyright" />
</p>
</div>
</footer>

View file

@ -0,0 +1,6 @@
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<nav class="navbar navbar-dark bg-inverse navbar-static-top pos-f-t">
<la:link styleClass="navbar-brand" href="/">
<img src="${f:url('/images/logo-head.png')}" alt="<la:message key="labels.header_brand_name" />" />
</la:link>
</nav>

View file

@ -0,0 +1,108 @@
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html>
<html>
<head profile="http://a9.com/-/spec/opensearch/1.1/">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title><la:message key="labels.profile.title" /></title>
<link href="${f:url('/css/style-base.css')}" rel="stylesheet"
type="text/css" />
<link href="${f:url('/css/style.css')}" rel="stylesheet" type="text/css" />
<link href="${f:url('/css/admin/style.css')}" rel="stylesheet"
type="text/css" />
<link href="${f:url('/css/admin/font-awesome.min.css')}"
rel="stylesheet" type="text/css" />
<link href="${f:url('/css/admin/AdminLTE.min.css')}" rel="stylesheet"
type="text/css" />
<link href="${f:url('/css/admin/skins/skin-blue.min.css')}"
rel="stylesheet" type="text/css" />
<!--[if lt IE 9]>
<script src="${f:url('/css/admin/html5shiv.min.js')}"></script>
<script src="${f:url('/css/admin/respond.min.js')}"></script>
<![endif]-->
</head>
<body class="hold-transition login-page">
<div class="login-box">
<div class="login-logo">
<la:link href="/">
<img src="${f:url('/images/logo-top.png')}"
alt="<la:message key="labels.header_brand_name" />" />
</la:link>
</div>
<!-- /.login-logo -->
<div class="login-box-body">
<p class="login-box-msg">
<la:message key="labels.profile" />
</p>
<p>
Username: ${username}
</p>
<%-- Message --%>
<div>
<la:info id="msg" message="false">
<div class="alert alert-info">${msg}</div>
</la:info>
<la:errors />
</div>
<la:form styleId="login" method="post">
<div class="form-group has-feedback">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock fa-fw"></i></span>
<c:set var="ph_old_password">
<la:message key="labels.profile.placeholder_old_password" />
</c:set>
<la:password property="oldPassword" class="form-control"
placeholder="${ph_old_password}" />
</div>
</div>
<div class="form-group has-feedback">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock fa-fw"></i></span>
<c:set var="ph_new_password">
<la:message key="labels.profile.placeholder_new_password" />
</c:set>
<la:password property="newPassword" class="form-control"
placeholder="${ph_new_password}" />
</div>
</div>
<div class="form-group has-feedback">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock fa-fw"></i></span>
<c:set var="ph_confirm_password">
<la:message key="labels.profile.placeholder_confirm_new_password" />
</c:set>
<la:password property="confirmPassword" class="form-control"
placeholder="${ph_confirm_password}" />
</div>
</div>
<div class="row">
<div class="col-xs-3"></div>
<!-- /.col -->
<div class="col-xs-6">
<button type="submit" name="changePassword"
class="btn btn-primary btn-block btn-flat"
value="<la:message key="labels.profile.update"/>">
<i class="fa fa-sign-in"></i>
<la:message key="labels.profile.update" />
</button>
</div>
<!-- /.col -->
<div class="col-xs-3"></div>
<!-- /.col -->
</div>
</la:form>
</div>
<!-- /.login-box-body -->
</div>
<!-- /.login-box -->
<jsp:include page="footer.jsp" />
<input type="hidden" id="contextPath" value="${contextPath}" />
<script type="text/javascript"
src="${f:url('/js/jquery-2.1.4.min.js')}"></script>
<script type="text/javascript" src="${f:url('/js/bootstrap.js')}"></script>
<script type="text/javascript" src="${f:url('/js/admin/admin.js')}"></script>
</body>
</html>