Last active
February 25, 2020 06:49
-
-
Save Azsaturndx/cf03b6cfc5e3ed4aab55451faedcf8c3 to your computer and use it in GitHub Desktop.
Auto refresh user token - Code onTime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Prevent user session closing | |
* (Code onTime) | |
* AzsaturnDx (2020) - No copyright at all | |
* | |
* Prevents the user from logging out by constantly refreshing userToken (re-logging-in according to: daf.js) | |
* | |
* REQUIRES: Your COT project must have the Account Manager enabled. | |
*/ | |
var identities = $app.AccountManager.list(); | |
var lastUser = identities._lastUser && identities[identities._lastUser]; | |
var refreshInterval = 30; | |
refreshUsertokenLoop(); | |
function refreshUsertokenLoop() { | |
setTimeout(function () { | |
$app.refreshUserToken(lastUser, | |
//Success Callback | |
(result) => { | |
console.log(result); | |
}, | |
//Error Callback | |
(result) => { | |
console.log(result); | |
} | |
); | |
refreshUsertokenLoop(); | |
}, refreshInterval * 1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment