propro-utils 1.4.19 → 1.4.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/server/index.js +22 -15
package/package.json
CHANGED
package/src/server/index.js
CHANGED
|
@@ -151,16 +151,7 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
151
151
|
|
|
152
152
|
console.log('redirectUrl', redirectUrl);
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
if (!redirectUrl.startsWith('http://') && !redirectUrl.startsWith('https://')) {
|
|
157
|
-
if (redirectUrl.includes('localhost')) {
|
|
158
|
-
urlToRedirect = `http://${redirectUrl}`;
|
|
159
|
-
} else {
|
|
160
|
-
urlToRedirect = `https://${redirectUrl}`;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
154
|
+
const urlToRedirect = formatRedirectUrl(clientUrl);
|
|
164
155
|
|
|
165
156
|
console.log('urlToRedirect', urlToRedirect);
|
|
166
157
|
|
|
@@ -185,15 +176,31 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
185
176
|
function constructRedirectUrl(clientUrl, appName, clientId, redirectUri) {
|
|
186
177
|
console.log('constructRedirectUrl', clientUrl, appName, clientId, redirectUri);
|
|
187
178
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
179
|
+
const urlToRedirect = formatRedirectUrl(clientUrl)
|
|
180
|
+
|
|
181
|
+
return `${urlToRedirect}/signin?response_type=code&appName=${appName}&client_id=${clientId}&redirect_uri=${encodeURIComponent(redirectUri)}`;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Formats the redirect URL by adding 'http://' or 'https://' if necessary.
|
|
186
|
+
*
|
|
187
|
+
* @param {string} redirectUrl - The URL to be redirected.
|
|
188
|
+
* @return {string} The formatted redirect URL.
|
|
189
|
+
*/
|
|
190
|
+
function formatRedirectUrl(redirectUrl) {
|
|
191
|
+
let urlToRedirect;
|
|
192
|
+
|
|
193
|
+
if (!redirectUrl.startsWith('http://') && !redirectUrl.startsWith('https://')) {
|
|
194
|
+
if (redirectUrl.includes('localhost')) {
|
|
195
|
+
urlToRedirect = `http://${redirectUrl}`;
|
|
191
196
|
} else {
|
|
192
|
-
|
|
197
|
+
urlToRedirect = `https://${redirectUrl}`;
|
|
193
198
|
}
|
|
199
|
+
} else {
|
|
200
|
+
urlToRedirect = redirectUrl;
|
|
194
201
|
}
|
|
195
202
|
|
|
196
|
-
return
|
|
203
|
+
return urlToRedirect;
|
|
197
204
|
}
|
|
198
205
|
|
|
199
206
|
|