This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit c4ed02bf64592c73ce1197f9131de5660c437134 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Mon Jul 31 14:14:17 2017 +0200 réactivation d'un utilisateur + forcage de la validation de l'email. --- .../migration/h2/V3_0_0_4__add_banned_in_user.sql | 3 ++ .../postgresql/V3_0_0_4__add_banned_in_user.sql | 3 ++ pollen-persistence/src/main/xmi/pollen.properties | 2 +- pollen-persistence/src/main/xmi/pollen.zargo | Bin 26190 -> 26297 bytes .../pollen/rest/api/PollenRestApiApplication.java | 2 + .../PollenAuthenticationExceptionMapper.java | 5 ++ .../PollenEmailNotValidatedExceptionMapper.java | 5 ++ .../PollenUserBannedExceptionMapper.java | 20 +++++++ .../org/chorem/pollen/rest/api/v1/AuthApi.java | 13 +++-- .../chorem/pollen/rest/api/v1/PollenUserApi.java | 32 ------------ .../pollen/services/bean/PollenUserBean.java | 19 ++----- .../pollen/services/service/PollenUserService.java | 58 ++------------------- .../security/PollenUserBannedException.java | 34 ++++++++++++ .../services/service/security/SecurityService.java | 7 ++- pollen-ui-riot-js/src/main/web/i18n.json | 12 +++-- pollen-ui-riot-js/src/main/web/js/FetchService.js | 4 +- pollen-ui-riot-js/src/main/web/js/UserService.js | 17 +----- pollen-ui-riot-js/src/main/web/tag/SignIn.tag.html | 2 +- .../src/main/web/tag/UserCard.tag.html | 20 +------ .../src/main/web/tag/UserEditModal.tag.html | 27 ++++++++++ 20 files changed, 134 insertions(+), 151 deletions(-) diff --git a/pollen-persistence/src/main/resources/db/migration/h2/V3_0_0_4__add_banned_in_user.sql b/pollen-persistence/src/main/resources/db/migration/h2/V3_0_0_4__add_banned_in_user.sql new file mode 100644 index 00000000..eb140378 --- /dev/null +++ b/pollen-persistence/src/main/resources/db/migration/h2/V3_0_0_4__add_banned_in_user.sql @@ -0,0 +1,3 @@ +-- add banned in pollenuser +alter table pollenuser add banned boolean; +update pollenuser set banned = password = ''; \ No newline at end of file diff --git a/pollen-persistence/src/main/resources/db/migration/postgresql/V3_0_0_4__add_banned_in_user.sql b/pollen-persistence/src/main/resources/db/migration/postgresql/V3_0_0_4__add_banned_in_user.sql new file mode 100644 index 00000000..eb140378 --- /dev/null +++ b/pollen-persistence/src/main/resources/db/migration/postgresql/V3_0_0_4__add_banned_in_user.sql @@ -0,0 +1,3 @@ +-- add banned in pollenuser +alter table pollenuser add banned boolean; +update pollenuser set banned = password = ''; \ No newline at end of file diff --git a/pollen-persistence/src/main/xmi/pollen.properties b/pollen-persistence/src/main/xmi/pollen.properties index 997cd1b8..4ee00b40 100644 --- a/pollen-persistence/src/main/xmi/pollen.properties +++ b/pollen-persistence/src/main/xmi/pollen.properties @@ -18,7 +18,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # #L% ###m -model.tagvalue.version=3.0.0.3 +model.tagvalue.version=3.0.0.4 #model.tagValue.notGenerateToString=true #model.tagValue.constantPrefix=PROPERTY_ #model.tagValue.useEnumerationName=true diff --git a/pollen-persistence/src/main/xmi/pollen.zargo b/pollen-persistence/src/main/xmi/pollen.zargo index 9489b909..a9447c7e 100644 Binary files a/pollen-persistence/src/main/xmi/pollen.zargo and b/pollen-persistence/src/main/xmi/pollen.zargo differ diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplication.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplication.java index 9f1711ae..897dfbcf 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplication.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplication.java @@ -12,6 +12,7 @@ import org.chorem.pollen.rest.api.exceptionMappers.PollenInvalidEmailActivationT import org.chorem.pollen.rest.api.exceptionMappers.PollenInvalidPermissionExceptionMapper; import org.chorem.pollen.rest.api.exceptionMappers.PollenInvalidSessionTokenExceptionMapper; import org.chorem.pollen.rest.api.exceptionMappers.PollenUnauthorizedExceptionMapper; +import org.chorem.pollen.rest.api.exceptionMappers.PollenUserBannedExceptionMapper; import org.chorem.pollen.rest.api.exceptionMappers.TopiaNoResultExceptionMapper; import org.chorem.pollen.rest.api.v1.AuthApi; import org.chorem.pollen.rest.api.v1.ChoiceApi; @@ -60,6 +61,7 @@ public class PollenRestApiApplication extends Application { new PollenInvalidPermissionExceptionMapper(), new PollenInvalidEmailActivationTokenExceptionMapper(), new PollenEmailNotValidatedExceptionMapper(), + new PollenUserBannedExceptionMapper(), new InvalidFormExceptionMapper(), new FavoriteListImportExceptionMapper(), new TopiaNoResultExceptionMapper(), diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/exceptionMappers/PollenAuthenticationExceptionMapper.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/exceptionMappers/PollenAuthenticationExceptionMapper.java index 2db84d94..c129298f 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/exceptionMappers/PollenAuthenticationExceptionMapper.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/exceptionMappers/PollenAuthenticationExceptionMapper.java @@ -12,4 +12,9 @@ public class PollenAuthenticationExceptionMapper extends PollenAbstractException public PollenAuthenticationExceptionMapper() { super(Response.Status.UNAUTHORIZED, true); } + + @Override + protected Object getEntity(PollenAuthenticationException exception) { + return "emailOrPasswordInvalid"; + } } diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/exceptionMappers/PollenEmailNotValidatedExceptionMapper.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/exceptionMappers/PollenEmailNotValidatedExceptionMapper.java index e5e2caaa..422d0d53 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/exceptionMappers/PollenEmailNotValidatedExceptionMapper.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/exceptionMappers/PollenEmailNotValidatedExceptionMapper.java @@ -12,4 +12,9 @@ public class PollenEmailNotValidatedExceptionMapper extends PollenAbstractExcept public PollenEmailNotValidatedExceptionMapper() { super(Response.Status.FORBIDDEN); } + + @Override + protected Object getEntity(PollenEmailNotValidatedException exception) { + return "emailNotValidated"; + } } diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/exceptionMappers/PollenUserBannedExceptionMapper.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/exceptionMappers/PollenUserBannedExceptionMapper.java new file mode 100644 index 00000000..9d74aee8 --- /dev/null +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/exceptionMappers/PollenUserBannedExceptionMapper.java @@ -0,0 +1,20 @@ +package org.chorem.pollen.rest.api.exceptionMappers; + +import org.chorem.pollen.services.service.security.PollenUserBannedException; + +import javax.ws.rs.core.Response; + +/** + * @author Sylvain Bavencoff - bavencoff@codelutin.com + */ +public class PollenUserBannedExceptionMapper extends PollenAbstractExceptionMapper<PollenUserBannedException> { + + public PollenUserBannedExceptionMapper() { + super(Response.Status.FORBIDDEN); + } + + @Override + protected Object getEntity(PollenUserBannedException exception) { + return "banned"; + } +} diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthApi.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthApi.java index b6eb9330..a96522f0 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthApi.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthApi.java @@ -36,6 +36,7 @@ import org.chorem.pollen.services.service.security.PollenCypherTechnicalExceptio import org.chorem.pollen.services.service.security.PollenEmailNotValidatedException; import org.chorem.pollen.services.service.security.PollenInvalidSessionTokenException; import org.chorem.pollen.services.service.security.PollenSecurityContext; +import org.chorem.pollen.services.service.security.PollenUserBannedException; import org.chorem.pollen.services.service.security.SecurityService; import javax.ws.rs.Consumes; @@ -100,10 +101,11 @@ public class AuthApi { @Context SecurityService securityService, @Context PollenSecurityContext securityContext) throws PollenAuthenticationException, - MissingAuthenticationException, - PollenInvalidSessionTokenException, - PollenCypherTechnicalException, - PollenEmailNotValidatedException { + MissingAuthenticationException, + PollenInvalidSessionTokenException, + PollenCypherTechnicalException, + PollenEmailNotValidatedException, + PollenUserBannedException { if (StringUtils.startsWith(authHeader, "Basic ")) { String s = new String(Base64.decode(StringUtils.substringAfter(authHeader, "Basic "))); @@ -166,7 +168,8 @@ public class AuthApi { @QueryParam("password") String password, @QueryParam("rememberMe") Boolean rememberMe) throws PollenAuthenticationException, - PollenEmailNotValidatedException { + PollenEmailNotValidatedException, + PollenUserBannedException { return securityService.login(login, password, rememberMe); diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java index 79c07e9f..123e13c3 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java @@ -104,13 +104,6 @@ public class PollenUserApi { } - @Path("/users/{userId}/admin") - @POST - public PollenUserBean adminUser(@Context PollenUserService pollenUserService, - PollenUserBean user) { - return pollenUserService.adminUser(user); - } - @Path("/users/{userId}") @DELETE public void deleteUser(@Context PollenUserService pollenUserService, @@ -121,31 +114,6 @@ public class PollenUserApi { } - @Path("/users/{userId}/ban") - @DELETE - public void banUser(@Context PollenUserService pollenUserService, - @PathParam("userId") PollenEntityId<PollenUser> userId, - @QueryParam("anonymize") boolean anonymize) { - - pollenUserService.banUser(userId.getEntityId(), anonymize); - } - - @Path("/users/{userId}/makeAdmin") - @POST - public void makeAdmin(@Context PollenUserService pollenUserService, - @PathParam("userId") PollenEntityId<PollenUser> userId) { - - pollenUserService.makeAdmin(userId.getEntityId()); - } - - @Path("/users/{userId}/unmakeAdmin") - @POST - public void unmakeAdmin(@Context PollenUserService pollenUserService, - @PathParam("userId") PollenEntityId<PollenUser> userId) { - - pollenUserService.unmakeAdmin(userId.getEntityId()); - } - @Path("/users/{userId}") @PUT public void validateUserEmail(@Context PollenUserService pollenUserService, diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollenUserBean.java b/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollenUserBean.java index a5994e6a..9bb64057 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollenUserBean.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollenUserBean.java @@ -21,7 +21,6 @@ package org.chorem.pollen.services.bean; * #L% */ -import org.apache.commons.lang3.StringUtils; import org.chorem.pollen.persistence.entity.PollenUser; import org.chorem.pollen.persistence.entity.PollenUserImpl; @@ -43,9 +42,7 @@ public class PollenUserBean extends PollenBean<PollenUser> { protected String password; - protected boolean isDisabled; - - protected boolean isBanned; + protected boolean banned; protected boolean emailIsValidate; @@ -60,7 +57,7 @@ public class PollenUserBean extends PollenBean<PollenUser> { setName(entity.getName()); setAdministrator(entity.isAdministrator()); - setBanned(StringUtils.isEmpty(entity.getPassword())); + setBanned(entity.isBanned()); setLanguage(entity.getLanguage()); setEmail(entity.getEmail()); setPassword(entity.getPassword()); @@ -124,14 +121,6 @@ public class PollenUserBean extends PollenBean<PollenUser> { this.password = password; } - public boolean isDisabled() { - return isDisabled; - } - - public void setDisabled(boolean isDisabled) { - this.isDisabled = isDisabled; - } - public boolean isEmailIsValidate() { return emailIsValidate; } @@ -141,10 +130,10 @@ public class PollenUserBean extends PollenBean<PollenUser> { } public boolean isBanned() { - return isBanned; + return banned; } public void setBanned(boolean banned) { - isBanned = banned; + this.banned = banned; } } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java index b399aa8b..1edc1687 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java @@ -57,8 +57,6 @@ import static org.nuiton.i18n.I18n.l; public class PollenUserService extends PollenServiceSupport implements PollenService { private final Function<PollenUserBean, PollenUserBean> pollenUserFunction = input -> { - input.setDisabled(Objects.equals(input.getPassword(), "")); - input.setPassword(null); return input; @@ -125,18 +123,6 @@ public class PollenUserService extends PollenServiceSupport implements PollenSer } - public PollenUserBean adminUser(PollenUserBean user) { - checkNotNull(user); - checkIsAdmin(); - - PollenUser userSaved = savePollenUser(user); - commit(); - - getNotificationService().onUserEdited(userSaved); - - return toBean(PollenUserBean.class, userSaved, pollenUserFunction); - } - public void deleteUser(String userId, boolean anonymize) { checkNotNull(userId); @@ -155,46 +141,6 @@ public class PollenUserService extends PollenServiceSupport implements PollenSer } - public void banUser(String userId, boolean anonymize) { - - checkNotNull(userId); - - PollenUser user = getUser0(userId); - - if (anonymize) { - anonymizeUser(user); - } - - user.setPassword(""); - commit(); - - getNotificationService().onUserEdited(user); - } - - public void makeAdmin(String userId) { - - checkNotNull(userId); - checkIsAdmin(); - - PollenUser user = getUser0(userId); - user.setAdministrator(true); - - commit(); - - } - - public void unmakeAdmin(String userId) { - - checkNotNull(userId); - checkIsAdmin(); - - PollenUser user = getUser0(userId); - user.setAdministrator(false); - - commit(); - - } - public void changePassword(String userId, String oldPassword, String newPassword) throws InvalidFormException { @@ -393,7 +339,11 @@ public class PollenUserService extends PollenServiceSupport implements PollenSer toSave.setAdministrator(user.isAdministrator()); toSave.setName(user.getName()); toSave.setLanguage(user.getLanguage()); + toSave.setBanned(user.isBanned()); toSave.setEmail(cleanMail); + if (user.isEmailIsValidate() && toSave.getEmailActivationToken() != null) { + toSave.setEmailActivationToken(null); + } return toSave; diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenUserBannedException.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenUserBannedException.java new file mode 100644 index 00000000..c49549a5 --- /dev/null +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenUserBannedException.java @@ -0,0 +1,34 @@ +package org.chorem.pollen.services.service.security; + +/* + * #%L + * Pollen :: Service + * %% + * Copyright (C) 2009 - 2017 Code Lutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +/** + * Error thrown when the user tires to login although he has not yet validated his email. + * + * @author Kevin Morin - morin@codelutin.com + */ +public class PollenUserBannedException extends Exception { + + public PollenUserBannedException() { + super("userBanned"); + } +} diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java index c3c04f29..8d4a42d5 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java @@ -122,7 +122,7 @@ public class SecurityService extends PollenServiceSupport { } public PollenEntityRef<PollenUser> login(String login, String password, Boolean rememberMe) - throws PollenAuthenticationException, PollenEmailNotValidatedException { + throws PollenAuthenticationException, PollenEmailNotValidatedException, PollenUserBannedException { Subject subject = getSubject(); UsernamePasswordToken token = new UsernamePasswordToken(login, password); @@ -140,6 +140,9 @@ public class SecurityService extends PollenServiceSupport { if (!user.isEmailValidated()) { throw new PollenEmailNotValidatedException(); } + if (user.isBanned()) { + throw new PollenUserBannedException(); + } // Generate a token PollenToken pollenToken = generateNewToken(); @@ -329,7 +332,7 @@ public class SecurityService extends PollenServiceSupport { String encodedPassword = serviceContext.encodePassword(user.getSalt(), password); boolean valid = Objects.equals(encodedPassword, user.getPassword()); - if (!valid) { + if (user.isBanned() || !valid) { throw new PollenInvalidPasswordException(); } diff --git a/pollen-ui-riot-js/src/main/web/i18n.json b/pollen-ui-riot-js/src/main/web/i18n.json index b353ea76..2089f9bc 100644 --- a/pollen-ui-riot-js/src/main/web/i18n.json +++ b/pollen-ui-riot-js/src/main/web/i18n.json @@ -200,8 +200,9 @@ "signin_password_placeholder": "Entrez votre mot de passe", "signin_lostpassword": "Mot de passe perdu ?", "signin_connexion": "Se connecter", - "signin_error_signin": "Courriel ou de mot de passe invalide", - "signin_error_signinemailNotValidated": "Vous devez valider votre compte avant de pouvoir vous connecter. Relevez vos emails, nous vous avons envoyé un lien de validation.", + "signin_error_signin_emailOrPasswordInvalid": "Courriel ou de mot de passe invalide", + "signin_error_signin_banned": "Compte bloqué", + "signin_error_signin_emailNotValidated": "Vous devez valider votre compte avant de pouvoir vous connecter. Relevez vos emails, nous vous avons envoyé un lien de validation.", "newpassword_title": "Obtenir un nouveau mot de passe", "newpassword_action": "Envoyer", "newpassword_placeholder": "Entrez votre courriel", @@ -358,6 +359,7 @@ "users_many": "utilisateurs", "user_banned": "Banni", "user_emailValidate": "En cours de validation", + "user_emailIsValidate": "Courriel validé", "user_administrator": "Administrateur", "user_edit": "Modifier l'utilisateur", "user_ban": "Désactiver", @@ -733,8 +735,9 @@ "signin_password_placeholder": "Enter your password", "signin_lostpassword": "Lost password?", "signin_connexion": "Connect", - "signin_error_signin": "Email or password invalid", - "signin_error_signinemailNotValidated": "You must validate your account before connecting. Check your emails, we sent you an activation link.", + "signin_error_signin_emailOrPasswordInvalid": "Email or password invalid", + "signin_error_signin_banned": "Bloked account", + "signin_error_signin_emailNotValidated": "You must validate your account before connecting. Check your emails, we sent you an activation link.", "newpassword_placeholder": "Fill your email", "newpassword_title": "Get a new password", "newpassword_action": "Send password", @@ -884,6 +887,7 @@ "users_many": "users", "user_banned": "banned", "user_emailValidate": "email validation waiting", + "user_emailIsValidate": "email validate", "user_administrator": "Administrator", "user_edit": "Edit user", "user_ban": "Ban", diff --git a/pollen-ui-riot-js/src/main/web/js/FetchService.js b/pollen-ui-riot-js/src/main/web/js/FetchService.js index 64146ff7..0b99b29c 100644 --- a/pollen-ui-riot-js/src/main/web/js/FetchService.js +++ b/pollen-ui-riot-js/src/main/web/js/FetchService.js @@ -56,11 +56,11 @@ class FetchService { } if (response.status === 401) { bus.trigger("unauthorize"); - return Promise.reject(); + return Promise.reject(response); } if (response.status === 503) { bus.trigger("unauthorize"); - return Promise.reject(); + return Promise.reject(response); } return Promise.reject(response); }, diff --git a/pollen-ui-riot-js/src/main/web/js/UserService.js b/pollen-ui-riot-js/src/main/web/js/UserService.js index e614ce68..58fe4c6e 100644 --- a/pollen-ui-riot-js/src/main/web/js/UserService.js +++ b/pollen-ui-riot-js/src/main/web/js/UserService.js @@ -43,28 +43,13 @@ class UserService extends FetchService { return this.get(url, {permission: permission}); } - makeAdmin(userId) { - let url = this._getUrlPrefix(userId) + "/makeAdmin"; - return this.post(url); - } - - unmakeAdmin(userId) { - let url = this._getUrlPrefix(userId) + "/unmakeAdmin"; - return this.post(url); - } - deleteUser(userId) { let url = this._getUrlPrefix(userId); return this.doDelete(url, {anonymize: true}); } - banUser(userId) { - let url = this._getUrlPrefix(userId) + "/ban"; - return this.doDelete(url, {anonymize: true}); - } - saveUser(user) { - let url = this._getUrlPrefix() + "/edit"; + let url = this._getUrlPrefix(user.id); return this.post(url, user); } diff --git a/pollen-ui-riot-js/src/main/web/tag/SignIn.tag.html b/pollen-ui-riot-js/src/main/web/tag/SignIn.tag.html index cc98c8a9..e6fb6efb 100644 --- a/pollen-ui-riot-js/src/main/web/tag/SignIn.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/SignIn.tag.html @@ -101,7 +101,7 @@ require("./components/HumanInput.tag.html"); this.update(); }, (response) => { response.text().then(error => { - this.message = this.__["error_signin" + error]; + this.message = this._l("error_signin_" + error); this.update(); }); }); diff --git a/pollen-ui-riot-js/src/main/web/tag/UserCard.tag.html b/pollen-ui-riot-js/src/main/web/tag/UserCard.tag.html index a1db6823..33ffec79 100644 --- a/pollen-ui-riot-js/src/main/web/tag/UserCard.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/UserCard.tag.html @@ -6,18 +6,10 @@ require("./UserEditModal.tag.html"); ondelete={delete} onedit={edit} class="user-card"> - <yield to="actions"> - <a class="warning" - if={!parent.opts.user.banned} - title={parent.__.banUser} - onclick={parent.banUser}> - <i class="fa fa-ban"></i> - </a> - </yield> <yield to="detail"> <div class="user-email"> - {parent.opts.user.email} <i class="fa fa-refresh" if={!parent.opts.user.emailIsValidate} title={parent.__.emailValidate}></i> + {parent.opts.user.email} </div> <div class="user-badges"> <span class="c-badge c-badge--rounded c-badge--success" @@ -72,16 +64,6 @@ require("./UserEditModal.tag.html"); this.editing = false; }; - this.banUser = () => { - this.confirm(this.__.banUserMessage, this.__.ban, "warning").then((confirm) => { - if (confirm) { - userService.banUser(this.opts.user.id).then(() => { - this.opts.onUserChange(); - }); - } - }); - }; - this.edit = () => { this.refs.editModal.open().then(() => { if (this.opts.onUserChange) { diff --git a/pollen-ui-riot-js/src/main/web/tag/UserEditModal.tag.html b/pollen-ui-riot-js/src/main/web/tag/UserEditModal.tag.html index 7c2eb995..e69b43da 100644 --- a/pollen-ui-riot-js/src/main/web/tag/UserEditModal.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/UserEditModal.tag.html @@ -36,6 +36,31 @@ require("./popup/Modal.tag.html"); </div> </label> </div> + <div class="o-form-element"> + <label class="c-toggle c-toggle--info"> + {parent.__.banned} + <input type="checkbox" + id="banned" + ref="banned" + checked={parent.opts.user.banned}> + <div class="c-toggle__track"> + <div class="c-toggle__handle"></div> + </div> + </label> + </div> + <div class="o-form-element"> + <label class="c-toggle c-toggle--info"> + {parent.__.emailIsValidate} + <input type="checkbox" + id="emailIsValidate" + ref="emailIsValidate" + disabled={parent.opts.user.emailIsValidate} + checked={parent.opts.user.emailIsValidate}> + <div class="c-toggle__track"> + <div class="c-toggle__handle"></div> + </div> + </label> + </div> </Modal> @@ -56,6 +81,8 @@ require("./popup/Modal.tag.html"); user2.name = this.refs.modal.refs.name.value; user2.email = this.refs.modal.refs.email.value; user2.administrator = this.refs.modal.refs.administrator.checked; + user2.banned = this.refs.modal.refs.banned.checked; + user2.emailIsValidate = this.refs.modal.refs.emailIsValidate.checked; return userService.saveUser(user2).then(() => { this.errors = {}; -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.