# useAuth0()

The useAuth0() composable allows for:

  • redirecting a user to the Auth0 login page,
  • redirecting a user to the Auth0 signup page,
  • redirecting a user to the Auth0 reset password page,
  • logging a user out of Auth0 and commercetools.

# login()

Redirects a user to the Auth0 login page.

Type

interface LoginParams {
  returnTo?: string;
}

function login(params?: LoginParams): void;

Example

<template>
  <button @click="login({ returnTo: '/' })">
    Login
  </button>
</template>

<script>
import { useAuth0 } from '@vsf-enterprise/ct-auth0';

export default {
  setup() {
    const { login } = useAuth0();

    return { login }
  }
};
</script>

`returnTo` will not work with the New Universal Login Page

Since the New Universal Login Page is not yet at feature parity with the Classic Universal Login Page, the returnTo param passed to the login method will have no effect while working with that version of the Auth0 Login Experience. To read more about the differences between both versions, visit the official Auth0 documentation (opens new window).

# register()

Redirects a user to the Auth0 signup page.

Type

interface RegisterParams {
  returnTo?: string;
}

function register(params: RegisterParams): void;

Example

<template>
  <button @click="register({ returnTo: '/' })">
    Register
  </button>
</template>

<script>
import { useAuth0 } from '@vsf-enterprise/ct-auth0';

export default {
  setup() {
    const { register } = useAuth0();

    return { register }
  }
};
</script>

# resetPassword()

Redirecting a user to the Auth0 reset password page.

Type

function resetPassword(): void;

Example

<template>
  <button @click="resetPassword">
    ResetPassword
  </button>
</template>

<script>
import { useAuth0 } from '@vsf-enterprise/ct-auth0';

export default {
  setup() {
    const { resetPassword } = useAuth0();

    return { resetPassword }
  }
};
</script>

# logout()

Logs a user out of Auth0 and Commercetools.

Type

function logout(): void;

Example

<template>
  <button @click="logout">
    Logout
  </button>
</template>

<script>
import { useAuth0 } from '@vsf-enterprise/ct-auth0';

export default {
  setup() {
    const { logout } = useAuth0();

    return { logout }
  }
};
</script>