|
3 | 3 | import static auth.AuthUtils.*;
|
4 | 4 | import static org.pac4j.core.client.IndirectClient.ATTEMPTED_AUTHENTICATION_SUFFIX;
|
5 | 5 | import static org.pac4j.play.store.PlayCookieSessionStore.*;
|
| 6 | +import static utils.FrontendConstants.FALLBACK_LOGIN; |
| 7 | +import static utils.FrontendConstants.GUEST_LOGIN; |
| 8 | +import static utils.FrontendConstants.PASSWORD_LOGIN; |
| 9 | +import static utils.FrontendConstants.PASSWORD_RESET; |
| 10 | +import static utils.FrontendConstants.SIGN_UP_LINK_LOGIN; |
6 | 11 |
|
7 | 12 | import auth.AuthUtils;
|
8 | 13 | import auth.CookieConfigs;
|
@@ -117,7 +122,8 @@ public Result authenticate(Http.Request request) {
|
117 | 122 | if (guestAuthenticationConfigs.isGuestEnabled()
|
118 | 123 | && guestAuthenticationConfigs.getGuestPath().equals(redirectPath)) {
|
119 | 124 | final String accessToken =
|
120 |
| - authClient.generateSessionTokenForUser(guestAuthenticationConfigs.getGuestUser()); |
| 125 | + authClient.generateSessionTokenForUser( |
| 126 | + guestAuthenticationConfigs.getGuestUser(), GUEST_LOGIN); |
121 | 127 | redirectPath =
|
122 | 128 | "/"; // We requested guest login by accessing {guestPath} URL. It is not really a target.
|
123 | 129 | CorpuserUrn guestUserUrn = new CorpuserUrn(guestAuthenticationConfigs.getGuestUser());
|
@@ -150,7 +156,8 @@ public Result authenticate(Http.Request request) {
|
150 | 156 |
|
151 | 157 | // 3. If no auth enabled, fallback to using default user account & redirect.
|
152 | 158 | // Generate GMS session token, TODO:
|
153 |
| - final String accessToken = authClient.generateSessionTokenForUser(DEFAULT_ACTOR_URN.getId()); |
| 159 | + final String accessToken = |
| 160 | + authClient.generateSessionTokenForUser(DEFAULT_ACTOR_URN.getId(), FALLBACK_LOGIN); |
154 | 161 | return Results.redirect(redirectPath)
|
155 | 162 | .withSession(createSessionMap(DEFAULT_ACTOR_URN.toString(), accessToken))
|
156 | 163 | .withCookies(
|
@@ -215,7 +222,8 @@ public Result logIn(Http.Request request) {
|
215 | 222 |
|
216 | 223 | final Urn actorUrn = new CorpuserUrn(username);
|
217 | 224 | logger.info("Login successful for user: {}, urn: {}", username, actorUrn);
|
218 |
| - final String accessToken = authClient.generateSessionTokenForUser(actorUrn.getId()); |
| 225 | + final String accessToken = |
| 226 | + authClient.generateSessionTokenForUser(actorUrn.getId(), PASSWORD_LOGIN); |
219 | 227 | return createSession(actorUrn.toString(), accessToken);
|
220 | 228 | }
|
221 | 229 |
|
@@ -279,7 +287,8 @@ public Result signUp(Http.Request request) {
|
279 | 287 | final String userUrnString = userUrn.toString();
|
280 | 288 | authClient.signUp(userUrnString, fullName, email, title, password, inviteToken);
|
281 | 289 | logger.info("Signed up user {} using invite tokens", userUrnString);
|
282 |
| - final String accessToken = authClient.generateSessionTokenForUser(userUrn.getId()); |
| 290 | + final String accessToken = |
| 291 | + authClient.generateSessionTokenForUser(userUrn.getId(), SIGN_UP_LINK_LOGIN); |
283 | 292 | return createSession(userUrnString, accessToken);
|
284 | 293 | }
|
285 | 294 |
|
@@ -319,7 +328,8 @@ public Result resetNativeUserCredentials(Http.Request request) {
|
319 | 328 | final Urn userUrn = new CorpuserUrn(email);
|
320 | 329 | final String userUrnString = userUrn.toString();
|
321 | 330 | authClient.resetNativeUserCredentials(userUrnString, password, resetToken);
|
322 |
| - final String accessToken = authClient.generateSessionTokenForUser(userUrn.getId()); |
| 331 | + final String accessToken = |
| 332 | + authClient.generateSessionTokenForUser(userUrn.getId(), PASSWORD_RESET); |
323 | 333 | return createSession(userUrnString, accessToken);
|
324 | 334 | }
|
325 | 335 |
|
|
0 commit comments