auth0-vue-samples icon indicating copy to clipboard operation
auth0-vue-samples copied to clipboard

Redirect users to a page after a signup to show "Please verify your email."

Open onurusluca opened this issue 3 years ago • 0 comments

Sorry for making a issue for this but I just can't figure it out. I wrote this a Auth0 community but couldn't get an answer.

I want to redirect users to a page after signup. Because now after a new signup the page keep refreshing itself. Login, logout etc. works fine.

Using the settings we discussed here: https://github.com/auth0/auth0-vue/issues/99#issuecomment-1102447205

I tried checking if user verified the email and redirect them but couldn't as I can't user useAuth0 outside Vue component. I can't figure it out. If I put this in App.vue it won't work because without auth the component isn't rendered. auth > expose auth > mount app

const { user } = useAuth0();
if (user.value.email_verified !== true) {
  console.warn(t("auth.verifyEmail"));
  router.push({
    name: "VerifyEmail",
  });
}

I don't know what settings to share here but here are some:

main.ts:

app.use(
  createAuth0({
    domain: EnvConfig.authDomain,
    client_id: EnvConfig.authClientId,
    redirect_uri: window.location.origin + EnvConfig.baseUrl,
    audience: EnvConfig.authAudience,
  })
);

ExposeAuth:

import { Auth0VueClient } from "@auth0/auth0-vue";
import { Ref } from "vue";

export const client: Ref<Auth0VueClient> = ref<Auth0VueClient>();

export function exposeAuth0() {
  return {
    install(app: {
      config: { globalProperties: { [x: string]: Auth0VueClient } };
    }) {
      client.value = app.config.globalProperties["$auth0"];
    },
  };
}

onurusluca avatar Aug 08 '22 05:08 onurusluca