Hi,
I am using okta Sign-in widget and just using plain standard JavaScript to implement it in one our legacy html page. I am not using any JS framework as the legacy pages does not support it. My requirement as follows:
“When the user password is expired, then without showing widget’s default password reset screen i want to navigate user to another html page to reset the password.”
I have looked at the github api for the sign in widget but i cannot find any resources which refers to my question. Please help me with this. My code as follows.
oktaSignIn.authClient.token.getUserInfo()
.then(function (user) {
console.log(user);
alert("Already logged in.");
window.location.href = "home.asp";
}, function (error) {
oktaSignIn.showSignInToGetTokens({
}).then(function (tokens) {
// Store tokens
oktaSignIn.authClient.tokenManager.setTokens(tokens);
oktaSignIn.remove();
alert("Hello, " + tokens.idToken.claims.email + "! You just logged in!");
}).catch(function (error) {
console.error("Sign in ERROR: " + error);
// This function is invoked with errors the widget cannot recover from:
// Known errors: CONFIG_ERROR, UNSUPPORTED_BROWSER_ERROR
});
})
.catch(function (err) {
console.error("SDK Error: " + err);
// handle OAuthError or AuthSdkError (AuthSdkError will be thrown if app is in OAuthCallback state)
});
oktaSignIn.authClient.authStateManager.subscribe((authState) => {
// handle the latest evaluated authState, like integrate with client framework's state management store
console.log(authState);
if (authState.isAuthenticated) {
console.log("SUCCESS and setting values");
window.location.href = "home.asp";
}
});
Thank you in advance,
Thusira.