cancel
Showing results for 
Search instead for 
Did you mean: 

My Share: Activate Disable & Enable User

vinaxwater
Champ in-the-making
Champ in-the-making
Case 1: request create new user but effect next week (this case for new staff)
Case 2: staff left off work but can't delete account (for report monthly)

All that cases I can build action Disable & Enable user
Step1: find file web-client-config-dialogs.xml add row

<dialog name="disableUser" page="/jsp/users/disable-user.jsp" managed-bean="DisableUserDialog"
                 icon="/images/icons/action_user.gif" title-id="title_disable_user"
                 description-id="disable_user_info" error-message-id="error_wizard" />
                
<dialog name="enableUser" page="/jsp/users/enable-user.jsp" managed-bean="EnableUserDialog"
                 icon="/images/icons/action_user.gif" title-id="title_enable_user"
                 description-id="enable_user_info" error-message-id="error_wizard" />
Step2: find file users.jsp add row

<a:booleanEvaluator value="#{r.userName != 'admin'}">
                                       <a:actionLink value="Disable" image="/images/icons/locked.gif" showLink="false" action="dialog:disableUser" actionListener="#{DisableUserDialog.setupUserAction}">
                                          <f:param name="id" value="#{r.id}" />
                                       </a:actionLink>
                                    </a:booleanEvaluator>
                                   
<a:booleanEvaluator value="#{r.userName != 'admin'}">
                                       <a:actionLink value="Enable" image="/images/icons/unlock.gif" showLink="false" action="dialog:enableUser" actionListener="#{EnableUserDialog.setupUserAction}">
                                          <f:param name="id" value="#{r.id}" />
                                       </a:actionLink>
                                    </a:booleanEvaluator>
Step3: coppy file delete-user.jsp then rename disable-user.jsp & enable-user.jsp
Step4: coppy file DeleteUserDialog.java then rename DisableUserDialog.java & EnableUserDialog.java
in 2 file DisableUserDialog.java and EnableUserDialog.java find & remove row

authenticationService.deleteAuthentication(userName);
this.personService.deletePerson(userName);
add row in DisableUserDialog.java:

authenticationService.setAuthenticationEnabled(userName, false);
add row in EnableUserDialog.java:

authenticationService.setAuthenticationEnabled(userName, true);
Step5: build

Hope this useful for you!
2 REPLIES 2

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
This does not work in multy tenant enviroment, you chouls use
navigator.getCurrentUser().isAdmin();

not if(user=='admin'). because admin may not have username admin, you can change this. and if this is in tenant blatruc then username is admin@blatruc.

also should be added : when and why user was disabled.

vinaxwater
Champ in-the-making
Champ in-the-making
Thanks for your idea but that demo code with my system. You can customize for your needs!
Username admin is user system because can not disable this user hiihii. Other users updated permission to administrator can disable from user admin or user have permission administrator or disable own hiihii. You can write log for that action disable!
For upgrade permission user to administrator in file authority-services-context.xml:

<property name="adminUsers">
            <set>
             <value>admin</value>
             <value>backup1</value>
             <value>backup2</value>
             <value>backup3</value>
             <value>backup4</value>
             <value>backup5</value>
          </set>
</property>
build source code again

Nice to meet you!