https://supertokens.com/ logo
#support-questions
Title
# support-questions
s

sharma

07/18/2022, 1:18 AM
Getting this error on calling
supertokensEmailPassword.resetPassword
Copy code
emailpassword.js:1 Uncaught (in promise) Error: SuperTokensWindowHandler must be initialized before calling this method.
    at e.getReferenceOrThrow (emailpassword.js:1:105686)
    at t.getQueryParams (emailpassword.js:1:35831)
    at Object.getResetPasswordTokenFromURL (emailpassword.js:1:22726)
    at e.getResetPasswordTokenFromURL (emailpassword.js:1:14504)
    at resetPassword (reset-password?token=NjJjZTUxOTA2MWI2NmE5NmQ2NzYyNjlmOWQyOWE1OTVhZGJiNTYxNWU5NDk3YzU2ZDJlYjNhNTJkYmRkMzU4ZjYwMzM4YmJlOGZkODcyNTRhN2Y0ODQ1YmNkNDZjMmEw&rid=emailpassword:25:70)
r

rp

07/18/2022, 4:16 AM
Hey! Which SDK is this from? And how are you using this SDK?
Also, have you called the supertokens.init function?
s

sharma

07/18/2022, 4:50 AM
sdk - web-js yes, I have called supertokens.init fn
I have this on every page on top of all other js scripts
Copy code
supertokens.init({
  appInfo: {
    appName: "...",
    apiDomain:
      "http://localhost:8080" /**Change it to your website domain where this project is deployed */,
    apiBasePath: "/api",
    onHandleEvent: (context) => {
      console.log("SuperTokens event received");
      if (context.action === "UNAUTHORISED") {
        console.log("Unauthorized access");
        alert("You are logged out. Will redirect to login screen.");
        window.location.replace("/auth?redirectToPath=" + location.pathname);
        // called when the user doesn't have a valid session but made a request that requires one
        // NOTE: This event can fire multiple times

        if (context.sessionExpiredOrRevoked) {
          // the sessionExpiredOrRevoked property is set to true if the current call cleared the session from storage
          // this happens only once, even if multiple tabs sharing the same session are open, making it useful for analytics purposes
        }
      }
    }
  },
    recipeList: [
        supertokensSession.init(),
        supertokensEmailPassword.init()
    ],
});
r

rp

07/18/2022, 4:54 AM
Hmm. Got it. And other functions work as expected?
Just this one fails?
s

sharma

07/18/2022, 5:14 AM
yes. signin, signup, email token for pass reset. they all work
r

rp

07/18/2022, 5:37 AM
Hmm ok thanks. Can you open an issue about it?
@nkshah2 can help.
n

nkshah2

07/18/2022, 5:39 AM
Hi @sharma, can you post the URLs you used for
supertokens
,
supertokensSession
and
supertokensEmailPassword
when adding them as scripts
We have identified the issue and are working on a fix
s

sharma

07/18/2022, 1:35 PM
n

nkshah2

07/18/2022, 1:37 PM
Right, we are working on a fix (will be released today). Ill get back to you on this
Change your script imports to be
Copy code
<script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-web-js@0.1.3/bundle/website.js" />
<script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-web-js@0.1.3/bundle/supertokens.js" />
<script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-web-js@0.1.3/bundle/session.js" />
<script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-web-js@0.1.3/bundle/emailpassword.js" />
And see if that solves the issue. Note the version in the script URL is just to make sure that jsdelivr does not serve you a cached version (usually takes 24 hours for newer versions to reflect on their CDN)
s

sharma

07/19/2022, 9:50 AM
Tried that. I am getting this error now
Copy code
reset-password?token=thetoken&rid=emailpassword:27 Uncaught (in promise) TypeError: supertokensEmailPassword.resetPassword is not a function
n

nkshah2

07/19/2022, 9:52 AM
resetPassword
is not a function, I think you meant to call
submitNewPassword
. Refer to https://supertokens.com/docs/web-js/modules/recipe_emailpassword.html for all the functions you can call
s

sharma

07/19/2022, 10:50 AM
submitNewPassword works. Everything is fixed now. Thanks
3 Views