Skip to content

Commit 51e6e65

Browse files
author
Sachin Maheshwari
committed
adding resSource at login pop-up
1 parent ecff269 commit 51e6e65

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

web-assets/js/setupAuth0.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,19 @@ const qs = (function (a) {
2323

2424
const authSetup = function () {
2525

26-
const domain = '<tenant>';
27-
const clientId = '<client-id>';
26+
const domain = 'topcoder-dev.auth0.com';
27+
const clientId = 'BXWXUWnilVUPdN01t2Se29Tw2ZYNGZvH';
2828
const useLocalStorage = false;
2929
const useRefreshTokens = false;
3030
const v3JWTCookie = 'v3jwt';
3131
const tcJWTCookie = 'tcjwt';
3232
const tcSSOCookie = 'tcsso';
33-
const cookieExpireIn = 30; // 30 mins
34-
const refreshTokenInterval = 300000; // in milliseconds
35-
const refreshTokenOffset = 60;
33+
const cookieExpireIn = 12*60; // 12 hrs
34+
const refreshTokenInterval = 60000; // in milliseconds
35+
const refreshTokenOffset = 65; // in seconds
3636
const returnAppUrl = qs['retUrl'];
3737
const shouldLogout = qs['logout'];
38+
const resSource = qs['resSource'];
3839

3940

4041
var auth0 = null;
@@ -45,6 +46,7 @@ const authSetup = function () {
4546
const registerSuccessUrl = host + '/register_success.html';
4647

4748
const init = function () {
49+
correctOldUrl();
4850
createAuth0Client({
4951
domain: domain,
5052
client_id: clientId,
@@ -110,7 +112,8 @@ const authSetup = function () {
110112
const login = function () {
111113
auth0
112114
.loginWithPopup({
113-
redirect_uri: host + '/callback.html'
115+
redirect_uri: host + '/callback.html',
116+
resSource: resSource
114117
})
115118
.then(function () {
116119
auth0.isAuthenticated().then(function (isAuthenticated) {
@@ -145,6 +148,7 @@ const authSetup = function () {
145148
if (callRefreshTokenFun != null) {
146149
clearInterval(callRefreshTokenFun);
147150
}
151+
refreshToken();
148152
callRefreshTokenFun = setInterval(refreshToken, refreshTokenInterval);
149153
}
150154
}
@@ -273,5 +277,13 @@ const authSetup = function () {
273277
}
274278
return hostDomain;
275279
}
280+
281+
function correctOldUrl() {
282+
let pattern = '#!/member';
283+
if (window.location.href.indexOf(pattern) > -1) {
284+
window.location.href = window.location.href.replace(pattern, '');
285+
}
286+
}
287+
276288
init();
277289
};

0 commit comments

Comments
 (0)