Kranos
05/21/2023, 8:27 PMasync function checkAuth(to, from, next) {
const canAccess = await Session.doesSessionExist();
if (!canAccess) return next("/signin");
else return next();
}
In my vue.js component that loads at /auth/verify-email I have a consumeVerificationCode() function that runs on mounted, having checked if there's a Session as per the documentation, see below:
async mounted() {
if (!this.session) {
await this.getSession();
this.consumeVerificationCode();
} else if (this.session) {
this.consumeVerificationCode();
}
},
The consumeVerificationCode() function is as follows:
async consumeVerificationCode() {
try {
let response = await verifyEmail();
if (response.status === "EMAIL_VERIFICATION_INVALID_TOKEN_ERROR") {
// This can happen if the verification code is expired or invalid.
// You should ask the user to retry
toast.error(
"Oops! Seems like the verification link expired. Please try again later."
);
this.$router.push("/auth/verify-email"); // back to the email sending screen.
} else {
// email was verified successfully.
toast.success("Email verified successfully!");
this.$router.push(this.userId + "/onboarding");
}
} catch (err) {
if (err.isSuperTokensGeneralError === true) {
// this may be a custom error message sent from the API by you.
toast.error(err.message);
} else {
toast.error(
"Oops! Seems like the verification link expired. Please try again later."
);
}
}
},
verifyEmail is imported as follows: import { verifyEmail } from "supertokens-web-js/recipe/emailverification";
The 404 error I receive isn't my custom 404 page - it displays what's seen in the attachment belownkshah2
05/22/2023, 6:16 AMrp_st
05/22/2023, 6:26 AMKranos
05/22/2023, 7:43 AMKranos
05/22/2023, 7:44 AMnkshah2
05/22/2023, 7:46 AMKranos
05/22/2023, 8:23 AMnkshah2
05/22/2023, 8:39 AMKranos
05/22/2023, 8:49 AMrp_st
05/22/2023, 9:42 AMKranos
05/22/2023, 9:43 AMrp_st
05/22/2023, 9:44 AM/auth
route on your app by typing in that path manually on the browser?Kranos
05/22/2023, 9:57 AMrp_st
05/22/2023, 9:58 AMrp_st
05/22/2023, 9:58 AM/home
or somethingKranos
05/22/2023, 10:00 AMrp_st
05/22/2023, 10:01 AMrp_st
05/22/2023, 10:02 AM/home
that serves the react bundle?Kranos
05/22/2023, 10:05 AMSuperTokens.init(SuperTokensWebJSConfig);
which is imported from ./config. In config I have the following:
export const SuperTokensWebJSConfig = {
appInfo: {
appName: import.meta.env.VITE_APP_APP_NAME,
apiDomain: import.meta.env.VITE_APP_API_URL,
websiteDomain: import.meta.env.VITE_APP_BASE_URL,
},
recipeList: [
EmailVerification.init(),
Session.init(),
ThirdPartyEmailPassword.init(),
],
};
rp_st
05/22/2023, 10:07 AMKranos
05/22/2023, 10:07 AMrp_st
05/22/2023, 10:07 AMrp_st
05/22/2023, 10:08 AMKranos
05/22/2023, 10:08 AMrp_st
05/22/2023, 10:08 AMrp_st
05/22/2023, 10:08 AMKranos
05/22/2023, 10:10 AMrp_st
05/22/2023, 10:10 AMKranos
05/22/2023, 10:26 AMrp_st
05/22/2023, 10:29 AMKranos
05/22/2023, 10:40 AMrp_st
05/22/2023, 10:41 AMKranos
05/22/2023, 10:41 AMKranos
05/22/2023, 6:49 PMrp_st
05/23/2023, 5:27 AM