Skip to content

Commit 9cb9565

Browse files
committed
Changed some method names in RoutesService to make it more consistent and added password change routes
1 parent adf3880 commit 9cb9565

File tree

12 files changed

+87
-21
lines changed

12 files changed

+87
-21
lines changed

ChangeLog

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
master
2+
- Changed some method names in RoutesService to make it more consistent and added password change routes
3+
- Pull request #517: Fixed mail and registration views to use RouteService (thanks @maohde)
4+
- Pull request #508: added type parameter (thanks @mkoester)
5+
- Pull request #511: Fix hardcoded execution context (thanks @danielkza)
16
3.0-M2 - 2015-01-26
27
- Pull request #480: Missing type parameter for RuntimeEnvironment (thanks @jaceklaskowski)
38
- Pull request #472: Soundcloud provider (thanks @amertum)

module-code/app/securesocial/controllers/MailTokenBasedOperations.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ abstract class MailTokenBasedOperations[U] extends SecureSocial[U] {
7777
env.userService.findToken(token).flatMap {
7878
case Some(t) if !t.isExpired && t.isSignUp == isSignUp => f(t)
7979
case _ =>
80-
val to = if (isSignUp) env.routes.signUpUrl else env.routes.resetPasswordUrl
80+
val to = if (isSignUp) env.routes.startSignUpUrl else env.routes.startResetPasswordUrl
8181
Future.successful(Redirect(to).flashing(Error -> Messages(BaseRegistration.InvalidLink)))
8282
}
8383
}

module-code/app/securesocial/core/authenticator/AuthenticatorStore.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ object AuthenticatorStore {
6262
*/
6363
class Default[A <: Authenticator[_]](cacheService: CacheService)(implicit executionContext: ExecutionContext)
6464
extends AuthenticatorStore[A] {
65-
65+
6666
/**
6767
* Retrieves an Authenticator from the cache
6868
*

module-code/app/securesocial/core/services/RoutesService.scala

+72-10
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,64 @@ import securesocial.core.IdentityProvider
2323
* A RoutesService that resolves the routes for some of the pages
2424
*/
2525
trait RoutesService {
26+
/**
27+
* The login page url
28+
*/
2629
def loginPageUrl(implicit req: RequestHeader): String
27-
def signUpUrl(implicit req: RequestHeader): String
30+
31+
/**
32+
* The page that starts the sign up flow
33+
*/
34+
def startSignUpUrl(implicit req: RequestHeader): String
35+
36+
/**
37+
* The url that processes submissions from the start sign up page
38+
*/
39+
def handleStartSignUpUrl(implicit req: RequestHeader): String
40+
41+
/**
42+
* The sign up page
43+
*/
2844
def signUpUrl(mailToken: String)(implicit req: RequestHeader): String
45+
46+
/**
47+
* The url that processes submissions from the sign up page
48+
*/
2949
def handleSignUpUrl(mailToken: String)(implicit req: RequestHeader): String
30-
def resetPasswordUrl(implicit req: RequestHeader): String
31-
def resetPasswordUrl(mailToken: String)(implicit req: RequestHeader): String
50+
51+
/**
52+
* The page that starts the reset password flow
53+
*/
54+
def startResetPasswordUrl(implicit req: RequestHeader): String
55+
56+
/**
57+
* The url that processes submissions from the start reset password page
58+
*/
3259
def handleStartResetPasswordUrl(implicit req: RequestHeader): String
33-
def handleStartResetPasswordUrl(mailToken: String)(implicit req: RequestHeader): String
60+
61+
/**
62+
* The reset password page
63+
*/
64+
def resetPasswordUrl(mailToken: String)(implicit req: RequestHeader): String
65+
66+
/**
67+
* The url that processes submissions from the reset password page
68+
*/
69+
def handleResetPasswordUrl(mailToken: String)(implicit req: RequestHeader): String
70+
71+
/**
72+
* The password change page
73+
*/
74+
def passwordChangeUrl(implicit req: RequestHeader): String
75+
76+
/**
77+
* The url that processes submissions from the password change page
78+
*/
79+
def handlePasswordChangeUrl(implicit req: RequestHeader): String
80+
81+
/**
82+
* The url to start an authentication flow with the given provider
83+
*/
3484
def authenticationUrl(provider: String, redirectTo: Option[String] = None)(implicit req: RequestHeader): String
3585
def faviconPath: Call
3686
def jqueryPath: Call
@@ -60,10 +110,14 @@ object RoutesService {
60110
absoluteUrl(securesocial.controllers.routes.LoginPage.login())
61111
}
62112

63-
override def signUpUrl(implicit req: RequestHeader): String = {
113+
override def startSignUpUrl(implicit req: RequestHeader): String = {
64114
absoluteUrl(securesocial.controllers.routes.Registration.startSignUp())
65115
}
66116

117+
override def handleStartSignUpUrl(implicit req: RequestHeader): String = {
118+
absoluteUrl(securesocial.controllers.routes.Registration.handleStartSignUp())
119+
}
120+
67121
override def signUpUrl(mailToken: String)(implicit req: RequestHeader): String = {
68122
absoluteUrl(securesocial.controllers.routes.Registration.signUp(mailToken))
69123
}
@@ -72,20 +126,28 @@ object RoutesService {
72126
absoluteUrl(securesocial.controllers.routes.Registration.handleSignUp(mailToken))
73127
}
74128

75-
override def resetPasswordUrl(implicit request: RequestHeader): String = {
129+
override def startResetPasswordUrl(implicit request: RequestHeader): String = {
76130
absoluteUrl(securesocial.controllers.routes.PasswordReset.startResetPassword())
77131
}
78132

133+
override def handleStartResetPasswordUrl(implicit req: RequestHeader): String = {
134+
absoluteUrl(securesocial.controllers.routes.PasswordReset.handleStartResetPassword())
135+
}
136+
79137
override def resetPasswordUrl(mailToken: String)(implicit req: RequestHeader): String = {
80138
absoluteUrl(securesocial.controllers.routes.PasswordReset.resetPassword(mailToken))
81139
}
82140

83-
override def handleStartResetPasswordUrl(implicit req: RequestHeader): String = {
84-
absoluteUrl(securesocial.controllers.routes.PasswordReset.handleStartResetPassword())
141+
override def handleResetPasswordUrl(mailToken: String)(implicit req: RequestHeader): String = {
142+
absoluteUrl(securesocial.controllers.routes.PasswordReset.handleResetPassword(mailToken))
85143
}
86144

87-
override def handleStartResetPasswordUrl(mailToken: String)(implicit req: RequestHeader): String = {
88-
absoluteUrl(securesocial.controllers.routes.PasswordReset.handleResetPassword(mailToken))
145+
override def passwordChangeUrl(implicit req: RequestHeader): String = {
146+
absoluteUrl(securesocial.controllers.routes.PasswordChange.page())
147+
}
148+
149+
override def handlePasswordChangeUrl(implicit req: RequestHeader): String = {
150+
absoluteUrl(securesocial.controllers.routes.PasswordChange.handlePasswordChange)
89151
}
90152

91153
override def authenticationUrl(provider: String, redirectTo: Option[String] = None)(implicit req: RequestHeader): String = {

module-code/app/securesocial/views/Registration/resetPasswordPage.scala.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ <h1>@Messages("securesocial.password.title")</h1>
1414
</div>
1515
}
1616

17-
<form action="@env.routes.handleStartResetPasswordUrl(mailToken)"
17+
<form action="@env.routes.handleResetPasswordUrl(mailToken)"
1818
class="form-horizontal"
1919
autocomplete="off"
2020
method="POST"

module-code/app/securesocial/views/Registration/startSignUp.scala.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ <h1>@Messages("securesocial.signup.title")</h1>
1313
</div>
1414
}
1515

16-
<form action="@env.routes.signUpUrl"
16+
<form action="@env.routes.handleStartSignUpUrl"
1717
class="form-horizontal"
1818
autocomplete="off" method="post"
1919
>

module-code/app/securesocial/views/mails/alreadyRegisteredEmail.scala.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
<p>Hello @user.firstName,</p>
66

77
<p>You tried to sign up but you already have an account with us. If you don't remember your password please go
8-
<a href="@env.routes.resetPasswordUrl">here</a> to reset it.</p>
8+
<a href="@env.routes.startResetPasswordUrl">here</a> to reset it.</p>
99
</body>
1010
</html>

module-code/app/securesocial/views/mails/signUpEmail.scala.html

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@(mailToken: String)(implicit request: RequestHeader, lang: Lang, env: securesocial.core.RuntimeEnvironment[_])
2-
@import securesocial.core.IdentityProvider
32
<html>
43
<body>
54
<p>Hello,</p>

module-code/app/securesocial/views/passwordChange.scala.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ <h1>@Messages("securesocial.passwordChange.title")</h1>
2323
<a class="btn" href="@securesocial.controllers.ProviderControllerHelper.landingUrl">@Messages("securesocial.passwordChange.okButton")</a>
2424
</div>
2525
} else {
26-
<form action="@securesocial.controllers.routes.PasswordChange.handlePasswordChange().absoluteURL(IdentityProvider.sslEnabled)"
26+
<form action="@env.routes.passwordChangeUrl"
2727
class="form-horizontal"
2828
autocomplete= "off"
2929
method="POST"

module-code/app/securesocial/views/provider.scala.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@
4545
<button type="submit" class="btn btn-primary">@Messages("securesocial.login.title")</button>
4646
</div>
4747
<div class="clearfix">
48-
<p><a href="@env.routes.resetPasswordUrl">@Messages("securesocial.login.forgotPassword") </a></p>
48+
<p><a href="@env.routes.startResetPasswordUrl">@Messages("securesocial.login.forgotPassword") </a></p>
4949
</div>
5050
@if(Play.current.configuration.getBoolean("securesocial.registrationEnabled").getOrElse(true) ){
5151
<div class="clearfix">
52-
<p>@Messages("securesocial.login.signUp") <a href="@env.routes.signUpUrl">@Messages("securesocial.login.here")</a></p>
52+
<p>@Messages("securesocial.login.signUp") <a href="@env.routes.startSignUpUrl">@Messages("securesocial.login.here")</a></p>
5353
</div>
5454
}
5555
</fieldset>

samples/java/demo/app/views/index.scala.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ <h2>OAuth2 Info</h2>
4242
}
4343
<hr>
4444
@user.main.passwordInfo.map { info =>
45-
<a class="btn" href="@securesocial.controllers.routes.PasswordChange.page.absoluteURL(Implicit.request(), IdentityProvider.sslEnabled)">Change Password</a>
45+
<a class="btn" href="@env.routes.passwordChangeUrl(Implicit.ctx()._requestHeader())">Change Password</a>
4646
}
4747

4848
<span>Link this account to

samples/scala/demo/app/views/index.scala.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ <h2>OAuth2 Info</h2>
4747
}
4848
<hr>
4949
@user.passwordInfo.map { info =>
50-
<a class="btn" href="@securesocial.controllers.routes.PasswordChange.page.absoluteURL(IdentityProvider.sslEnabled)">Change Password</a>
50+
<a class="btn" href="@env.routes.passwordChangeUrl">Change Password</a>
5151
}
5252

5353
<span>Link this account to

0 commit comments

Comments
 (0)