Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 30f42e8

Browse files
Merge pull request #1472 from CoderDojo/Fix-register-path
Add force_signup param to register path
2 parents 854b292 + 597c593 commit 30f42e8

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

web/controllers/rpi/index.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const Boom = require('boom');
66
const { URLSearchParams } = require('url');
77
const {
88
getRedirectUri,
9-
getRegisterRedirectUri,
109
getEditRedirectUri,
1110
getLogoutRedirectUri,
1211
getIdToken,
@@ -26,9 +25,7 @@ function getErrorRedirectUrl(message = oauthErrorMessage) {
2625
return `/?${errorUrlQueryParams}`;
2726
}
2827

29-
function handleRPILogin(request, reply) {
30-
let redirectQueryParams = {};
31-
if (request.query.mgrt) redirectQueryParams = { mgrt: request.query.mgrt };
28+
function handleRPILogin(request, reply, redirectQueryParams = {}) {
3229
const state = crypto.randomBytes(20).toString('hex');
3330
setRpiStateCookie(reply, { state });
3431
const redirectUri = getRedirectUri(state, redirectQueryParams);
@@ -57,8 +54,8 @@ function handleRPIRegister(request, reply) {
5754
if (session && session.token) {
5855
return reply.redirect('/');
5956
}
60-
const redirectUri = getRegisterRedirectUri();
61-
reply.redirect(redirectUri);
57+
58+
handleRPILogin(request, reply, { login_options: 'force_signup' })
6259
}
6360

6461
function handleRPIEdit(request, reply) {

web/lib/rpi-auth.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const rpiZenAccountPassword = process.env.RPI_ZEN_ACCOUNT_PWORD;
1212

1313
const profileOauthPath = '/oauth2/auth';
1414
const profileTokenPath = '/oauth2/token';
15-
const profileSignupPath = '/signup';
1615
const profileEditPath = '/profile/edit';
1716
const logoutPath = '/logout';
1817
const loginPath = '/login';
@@ -42,13 +41,6 @@ function getLogoutRedirectUri() {
4241
return `${profileServer}${logoutPath}?${params}`;
4342
}
4443

45-
function getRegisterRedirectUri() {
46-
const params = new URLSearchParams();
47-
params.set('brand', brand);
48-
params.set('returnTo', `${homeServer}${loginPath}`);
49-
return `${profileServer}${profileSignupPath}?${params}`;
50-
}
51-
5244
function getEditRedirectUri() {
5345
const params = new URLSearchParams();
5446
params.set('brand', brand);
@@ -125,7 +117,6 @@ module.exports = {
125117
decodeIdToken,
126118
getRedirectUri,
127119
getIdToken,
128-
getRegisterRedirectUri,
129120
getLogoutRedirectUri,
130121
rpiZenAccountPassword,
131122
getEditRedirectUri,

0 commit comments

Comments
 (0)