1.0.10 • Published 3 years ago

@gastienne/quasar-app-extension-auth v1.0.10

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Quasar App Extension plugin.auth

Add a short description of your App Extension. What does it do? How is it beneficial? Why would someone want to use it?

npm npm

Install

quasar ext add @gastienne/auth

Quasar CLI will retrieve it from NPM and install the extension.

Prompts

When installing the Auth app extension, you will be prompted with fourteen questions:

  1. Route for authentication

The default is /login, it allows you to define the login route

  1. Route where the user will be redirected once connected

The default is /, you can define where you want to be redirect once connected

  1. Route for code verification after performing the forgotten password

The default is /check_code, you can define other route

  1. Route for password update

The default is /reset_password

  1. Basic server route

The default is http://localhost:3000, you must point it to your server base url

  1. Server route for authentication

The default is /users/sign_in

  1. Server route to reset password

The default is /users/reset_password

  1. Server route to update password

The default is /users/passwords

  1. Authorization type

The default is Bearer but you can change it according to your needs

  1. Vuex mutation to set token

The default is auth/setToken in the auth module. It can be changed from the moment it takes the token in parameter

  1. Vuex mutation to clear token and all user state

The default is auth/clearToken in the auth module but can be changed

  1. Vuex mutation to set user information when resetting password (email or phone number)

The default is auth/setInfosUser in auth module. It takes email or phone number, can be changed

  1. Vuex getter to return token

The default is auth/getToken and return token, can be changed.

  1. Vuex getter to return user information

The default is auth/getInfosUser and return email or phone number

Uninstall

quasar ext remove @gastienne/auth

Info

The parent application must provide the following mutations:

A mutation to store the token, it takes the token in parameter

A mutation to clean the token and the user information

A mutation to define the user information during the process of forgotten password (email or phone number), it takes in parameter the email or the phone number.

A getter which returns the token

A getter that returns the email or the phone number defined during the process of forgotten password.

When installing the extension, the path to these mutations and getters must be provided. As well as the different routes of the pages and APIs, without forgetting the type of authorization.

Usage

In auth mutation:

export function setToken(state, payload) {
    state.token = payload
}

export function clearToken(state) {
    state.token = null
    state.emailOrPhoneNumber = null
}

export function setInfosUser(state, payload) {
    state.emailOrPhoneNumber = payload
}

In auth getter:

export function getToken(state) {
    return state.token
}

export function getInfosUser(state) {
    return state.emailOrPhoneNumber
}

Donate

If you appreciate the work that went into this App Extension, make donation to Sowell

License

MIT (c) Sowell