Skip to content

Commit 57a0a0c

Browse files
committed
fix: redirect url
1 parent 971f333 commit 57a0a0c

File tree

5 files changed

+5
-10
lines changed

5 files changed

+5
-10
lines changed

schemas/config.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,6 @@
530530
},
531531
"profileHandler": {
532532
"type": "object"
533-
},
534-
"redirectUrl": {
535-
"type": "string"
536533
}
537534
}
538535
}

src/actions/oauth/upgrade.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ async function upgrade(request) {
4242

4343
if (provider === 'apple') {
4444
try {
45-
const tokenResponse = await validateGrantCode(providerSettings, token);
45+
const redirectUrl = transportRequest.url.href.replace(/\/upgrade$/, '/apple');
46+
const tokenResponse = await validateGrantCode(providerSettings, token, redirectUrl);
4647
credentials = await profile(providerSettings, tokenResponse);
4748
credentials.query = query;
4849
} catch (error) {

src/auth/oauth/strategies/apple.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ async function getProfile(credentials, params) {
8585
return credentials;
8686
}
8787

88-
async function validateGrantCode(providerSettings, code) {
89-
const { provider, redirectUrl, clientId, clientSecret } = providerSettings;
88+
async function validateGrantCode(providerSettings, code, redirectUrl) {
89+
const { provider, clientId, clientSecret } = providerSettings;
9090
const response = await httpRequest.post(provider.token, {
9191
form: {
9292
code,
@@ -110,7 +110,6 @@ function getProvider(options, server) {
110110
password,
111111
isSameSite,
112112
cookie,
113-
redirectUrl,
114113
} = options;
115114

116115
// adds the "code" parameter to the query string for bell to work correctly
@@ -121,7 +120,6 @@ function getProvider(options, server) {
121120
clientId,
122121
isSameSite,
123122
cookie,
124-
redirectUrl,
125123
clientSecret: () => getSecretKey(teamId, clientId, keyId, privateKey),
126124
forceHttps: true,
127125
providerParams: {

src/configs/oauth.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ exports.oauth = {
5454
password: 'very-long-encryption-password-that-needs-to-be-changed',
5555
cookie: 'mf_bapp',
5656
isSameSite: 'Lax',
57-
redirectUrl: 'https://ms-users.local/users/oauth/upgrade', // used for upgrade token only!
5857
},
5958
},
6059
};

test/suites/actions/oauth/upgrade.apple.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const request = require('request-promise');
33
const Users = require('../../../../src');
44

55
// @TODO stub
6-
describe.skip('oauth.upgrade action', function suite() {
6+
describe('oauth.upgrade action', function suite() {
77
const service = new Users({ oauth: { providers: { apple: { enabled: true } } } });
88

99
before(() => service.connect());

0 commit comments

Comments
 (0)