Files
jandl-taskmanager-app/app/src/plugins/w/auth
2023-01-13 15:41:57 +01:00
..
2022-11-21 05:42:38 +01:00
2023-01-13 15:41:57 +01:00
2022-11-21 05:42:38 +01:00
2022-11-21 05:42:38 +01:00
2022-11-21 05:42:38 +01:00
2022-11-21 05:42:38 +01:00

W / Auth

  • This plugin is used for managing logged user, and will automatically inject auth store to your main store

Required third-party plugins

  • npm i vuex@4 && npm i axios-auth-refresh

Required internal plugins

  • w/axios

Installation

  1. Create store.ts in @/store.ts and initialize vuex store
  2. Import @/store.ts in main.ts
  3. Import w/auth in main.ts

Installation example

  • main.ts
import store from '@/store'
import auth from '@/plugins/w/auth'

const app = createApp(App)
	.use(store)
	.use(auth)
  • store.ts
import { createStore } from 'vuex'

export default createStore({
	modules: {}
})

Store actions

this.$store.dispatch('auth/login', credentials)
this.$store.dispatch('auth/signup', credentials)
this.$store.dispatch('auth/logout')
this.$store.dispatch('auth/forgotPassword', credentials)
this.$store.dispatch('auth/resetPassword', credentials)
this.$store.dispatch('auth/refreshToken')
this.$store.dispatch('auth/userInfo')
this.$store.dispatch('auth/updateUserInfo', user)

Store getters

this.$store.getters['auth/isLoggedIn']
this.$store.getters['auth/user']