Sign-in widget overriding the user flow of PASSWORD_EXPIRED

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.

It looks like there is a feature you can enable in the widget called customExpiredPassword but this relies on the Okta admin dashboard setting: Settings->Customization->User Account->Password Management->Password is managed by a different application

This is great, I will try this out. Do you know the impact of this customization to the other features of okta ?

I haven’t used that feature before so I’m not sure but would love to hear how your experience with it goes :grinning:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.