propro-utils 1.4.17 → 1.4.18

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "propro-utils",
3
- "version": "1.4.17",
3
+ "version": "1.4.18",
4
4
  "description": "Auth middleware for propro-auth",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -153,9 +153,11 @@ function proproAuthMiddleware(options = {}, userSchema) {
153
153
  let urlToRedirect;
154
154
 
155
155
  if (!redirectUrl.startsWith('http://') && !redirectUrl.startsWith('https://')) {
156
- urlToRedirect = redirectUrl.includes('app.mapmap.app') ? `https://${redirectUrl}/` : `http://${redirectUrl}/`;
157
- } else {
158
- urlToRedirect = redirectUrl;
156
+ if (redirectUrl.includes('localhost')) {
157
+ urlToRedirect = `http://${redirectUrl}`;
158
+ } else {
159
+ urlToRedirect = `https://${redirectUrl}`;
160
+ }
159
161
  }
160
162
 
161
163
 
@@ -181,7 +183,17 @@ function proproAuthMiddleware(options = {}, userSchema) {
181
183
  */
182
184
  function constructRedirectUrl(clientUrl, appName, clientId, redirectUri) {
183
185
  console.log('constructRedirectUrl', clientUrl, appName, clientId, redirectUri);
186
+
187
+ if (!clientUrl.startsWith('http://') && !clientUrl.startsWith('https://')) {
188
+ if (clientUrl.includes('localhost')) {
189
+ clientUrl = `http://${clientUrl}`;
190
+ } else {
191
+ clientUrl = `https://${clientUrl}`;
192
+ }
193
+ }
194
+
184
195
  return `${clientUrl}/signin?response_type=code&appName=${appName}&client_id=${clientId}&redirect_uri=${encodeURIComponent(redirectUri)}`;
185
196
  }
186
197
 
198
+
187
199
  module.exports = proproAuthMiddleware;