Skip to content

Commit 73d7b1b

Browse files
authored
Merge pull request #327 from watery/logout-new-user-2
Logout new user (configuration option) - needs review
2 parents e99c243 + c4d39e1 commit 73d7b1b

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

server/src/main/java/password/pwm/config/PwmSetting.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,8 @@ public enum PwmSetting
840840
"newUser.writeAttributes", PwmSettingSyntax.ACTION, PwmSettingCategory.NEWUSER_PROFILE ),
841841
NEWUSER_DELETE_ON_FAIL(
842842
"newUser.deleteOnFail", PwmSettingSyntax.BOOLEAN, PwmSettingCategory.NEWUSER_PROFILE ),
843+
NEWUSER_LOGOUT_AFTER_CREATION(
844+
"newUser.logoutAfterCreation", PwmSettingSyntax.BOOLEAN, PwmSettingCategory.NEWUSER_PROFILE ),
843845
NEWUSER_USERNAME_DEFINITION(
844846
"newUser.username.definition", PwmSettingSyntax.STRING_ARRAY, PwmSettingCategory.NEWUSER_PROFILE ),
845847
NEWUSER_EMAIL_VERIFICATION(

server/src/main/java/password/pwm/http/servlet/newuser/NewUserServlet.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import password.pwm.http.PwmSession;
4545
import password.pwm.http.PwmURL;
4646
import password.pwm.http.bean.NewUserBean;
47+
import password.pwm.http.filter.AuthenticationFilter;
4748
import password.pwm.http.servlet.AbstractPwmServlet;
4849
import password.pwm.http.servlet.ControlledPwmServlet;
4950
import password.pwm.http.servlet.PwmServletDefinition;
@@ -707,6 +708,25 @@ private ProcessStatus handleComplete(
707708
// -- process complete -- \\
708709
pwmRequest.getPwmApplication().getSessionStateService().clearBean( pwmRequest, NewUserBean.class );
709710

711+
if ( pwmRequest.isAuthenticated() )
712+
{
713+
final PwmSession pwmSession = pwmRequest.getPwmSession();
714+
715+
if ( AuthenticationFilter.forceRequiredRedirects( pwmRequest ) == ProcessStatus.Halt )
716+
{
717+
return ProcessStatus.Halt;
718+
}
719+
720+
// log the user out if the current profiles states so
721+
final boolean forceLogoutOnChange = newUserProfile.readSettingAsBoolean( PwmSetting.NEWUSER_LOGOUT_AFTER_CREATION );
722+
if ( forceLogoutOnChange )
723+
{
724+
LOGGER.trace( pwmSession, "logging out user; account created" );
725+
pwmRequest.sendRedirect( PwmServletDefinition.Logout );
726+
return ProcessStatus.Halt;
727+
}
728+
}
729+
710730
final String configuredRedirectUrl = newUserProfile.readSettingAsString( PwmSetting.NEWUSER_REDIRECT_URL );
711731
if ( !StringUtil.isEmpty( configuredRedirectUrl ) && StringUtil.isEmpty( pwmRequest.getPwmSession().getSessionStateBean().getForwardURL() ) )
712732
{

server/src/main/resources/password/pwm/config/PwmSetting.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,6 +2751,11 @@
27512751
<value>true</value>
27522752
</default>
27532753
</setting>
2754+
<setting hidden="false" key="newUser.logoutAfterCreation" level="2">
2755+
<default>
2756+
<value>false</value>
2757+
</default>
2758+
</setting>
27542759
<setting hidden="false" key="newUser.username.definition" level="1">
27552760
<default>
27562761
<value><![CDATA[@RandomChar:16:ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@]]></value>

server/src/main/resources/password/pwm/i18n/PwmSetting.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ Setting_Description_newUser.deleteOnFail=Enable this option to have @PwmAppName@
493493
Setting_Description_newUser.email.verification=Enable this option to have @PwmAppName@ send an email to the new user's email address before it creates the account. The new user must verify receipt of the email before @PwmAppName@ creates the account. All of your email settings must also be filled out before this will work. Testing the email settings should take place to verify that this email will be sent.
494494
Setting_Description_newUser.enable=Enable this option to allow @PwmAppName@ to display the new user registration.
495495
Setting_Description_newUser.form=Specify the New User form creation attributes and fields. This is used to determine what information will need to be filled in before submitting the new user form to create the new user.
496+
Setting_Description_newUser.logoutAfterCreation=Enable this option to force the new user to log out (and send him to the logoutURL) after the account has been created.<br/><br/>Leave this option disabled (default) to make @PwmAppName@ automatically login the new user.
496497
Setting_Description_newUser.minimumWaitTime=Specify a delay time during a new user creation. @PwmAppName@ delays the creation of the user for at least this amount of time before forwarding the user to the next activity. <br/><br/>Specify the value in seconds.
497498
Setting_Description_newUser.passwordPolicy.user=Specify a valid LDAP user DN that @PwmAppName@ can use as a template for the new user password policy. If the value is the literal value "<b>TESTUSER</b>", @PwmAppName@ uses the configured test user's password policy as the policy for the new user prior to its actual creation in the LDAP directory.
498499
Setting_Description_newUser.profile.displayName=Specify the publicly viewable display name of this profile. This value will only be seen if the profile was enabled to be shown publicly.
@@ -1013,6 +1014,7 @@ Setting_Label_newUser.deleteOnFail=Delete On Creation Failure
10131014
Setting_Label_newUser.email.verification=Enable New User Email Verification
10141015
Setting_Label_newUser.enable=Enable New User Registration
10151016
Setting_Label_newUser.form=New User Form
1017+
Setting_Label_newUser.logoutAfterCreation=Logout After Creation
10161018
Setting_Label_newUser.minimumWaitTime=New User Minimum Wait Time
10171019
Setting_Label_newUser.passwordPolicy.user=Password Policy Template
10181020
Setting_Label_newUser.profile.displayName=Profile Display Name

0 commit comments

Comments
 (0)