Skip to content

Commit

Permalink
Merge pull request jaliss#160 from magro/overridable-registration-ste…
Browse files Browse the repository at this point in the history
…p-targets

Allow overriding Registration step redirect targets.
  • Loading branch information
jaliss committed Feb 27, 2013
2 parents 9ef19a9 + cbda5e8 commit 2bb68c2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
8 changes: 8 additions & 0 deletions docs/src/manual/source/guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ These settings go in the `smtp` section of the `securesocial.conf` file:

- `onLogoutGoTo`: The page where the user is redirected to after logging out.

- `onStartSignUpGoTo`: The page where the user is redirected to after sign up was started (form with email address was submitted/processed)

- `onSignUpGoTo`: The page where the user is redirected to after sign-up was completed (full sign up form was submitted/processed)

- `onStartResetPasswordGoTo`: The page where the user is redirected to after password reset was started (form with email address was submitted/processed)

- `onResetPasswordGoTo`: The page where the user is redirected to after the password was reset (change password form was submitted/processed)

- `ssl`: You can enable SSL for OAuth callbacks, the login, signup and reset password actions of the `UsernamePasswordProvider` and for the cookie used to trace users (you'll want this in production mode).

- `assetsController`: This setting is optional. It is only needed if you are not using the default Assets controller provided by Play. The value must be the full qualified class name of your controller prepended by the word Reverse.
Expand Down
21 changes: 17 additions & 4 deletions module-code/app/securesocial/controllers/Registration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ object Registration extends Controller {
val TokenDurationKey = "securesocial.userpass.tokenDuration"
val DefaultDuration = 60
val TokenDuration = Play.current.configuration.getInt(TokenDurationKey).getOrElse(DefaultDuration)

/** The redirect target of the handleStartSignUp action. */
val onHandleStartSignUpGoTo = stringConfig("securesocial.onStartSignUpGoTo", RoutesHelper.login().url)
/** The redirect target of the handleSignUp action. */
val onHandleSignUpGoTo = stringConfig("securesocial.onSignUpGoTo", RoutesHelper.login().url)
/** The redirect target of the handleStartResetPassword action. */
val onHandleStartResetPasswordGoTo = stringConfig("securesocial.onStartResetPasswordGoTo", RoutesHelper.login().url)
/** The redirect target of the handleResetPassword action. */
val onHandleResetPasswordGoTo = stringConfig("securesocial.onResetPasswordGoTo", RoutesHelper.login().url)

private def stringConfig(key: String, default: => String) = {
Play.current.configuration.getString(key).getOrElse(default)
}

case class RegistrationInfo(userName: Option[String], firstName: String, lastName: String, password: String)

Expand Down Expand Up @@ -160,7 +173,7 @@ object Registration extends Controller {
Mailer.sendSignUpEmail(email, token._1)
}
}
Redirect(RoutesHelper.login()).flashing(Success -> Messages(ThankYouCheckEmail), Email -> email)
Redirect(onHandleStartSignUpGoTo).flashing(Success -> Messages(ThankYouCheckEmail), Email -> email)
}
)
}
Expand Down Expand Up @@ -224,7 +237,7 @@ object Registration extends Controller {
if ( UsernamePasswordProvider.signupSkipLogin ) {
ProviderController.completeAuthentication(user, eventSession).flashing(Success -> Messages(SignUpDone))
} else {
Redirect(RoutesHelper.login()).flashing(Success -> Messages(SignUpDone)).withSession(eventSession)
Redirect(onHandleSignUpGoTo).flashing(Success -> Messages(SignUpDone)).withSession(eventSession)
}
}
)
Expand All @@ -250,7 +263,7 @@ object Registration extends Controller {
Mailer.sendUnkownEmailNotice(email)
}
}
Redirect(RoutesHelper.login()).flashing(Success -> Messages(ThankYouCheckEmail))
Redirect(onHandleStartResetPasswordGoTo).flashing(Success -> Messages(ThankYouCheckEmail))
}
)
}
Expand Down Expand Up @@ -281,7 +294,7 @@ object Registration extends Controller {
( (Error -> Messages(ErrorUpdatingPassword)), None)
}
}
val result = Redirect(RoutesHelper.login()).flashing(toFlash)
val result = Redirect(onHandleResetPasswordGoTo).flashing(toFlash)
eventSession.map( result.withSession(_) ).getOrElse(result)
})
})
Expand Down
4 changes: 4 additions & 0 deletions module-code/conf/securesocial/defaults.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
securesocial {
onLoginGoTo=/
onLogoutGoTo=/login
onStartSignUpGoTo=/login
onSignUpGoTo=/login
onStartResetPasswordGoTo=/login
onResetPasswordGoTo=/login

twitter {
requestTokenUrl="https://twitter.com/oauth/request_token"
Expand Down

0 comments on commit 2bb68c2

Please sign in to comment.