반응형
Features-vuex persistState 설치에도 불구하고 인증 상태가 유지되지 않음
약간의 문제가 있습니다.
Vue 2에서 깃털과 Vuex를 사용하여 프로젝트를 만들고 있습니다.
이 프로젝트에는 내 개인적인 프로젝트/경험/메시지가 모두 포함된 대시보드가 있습니다.
로그인하여 대시보드로 리디렉션하면 모든 데이터가 검색되지만 페이지를 새로 고치면 인증되지 않았습니다.라는 Featers 오류가 나타납니다.
에러: flatures error 이미지
여기 내 스토어/인덱스.인덱스:
import Vue from 'vue'
import Vuex from 'vuex'
import { FeathersVuex } from '../feathers-client'
import auth from './store.auth'
import createPersistedState from "vuex-persistedstate";
Vue.use(Vuex)
Vue.use(FeathersVuex)
const requireModule = require.context(
// The path where the service modules live
'./services',
// Whether to look in subfolders
false,
// Only include .js files (prevents duplicate imports`)
/\.js$/
)
const servicePlugins = requireModule
.keys()
.map(modulePath => requireModule(modulePath).default)
export default new Vuex.Store({
state: {},
mutations: {},
actions: {},
plugins: [...servicePlugins, createPersistedState({storage: window.localStorage}), auth]
})
여기 Vue 패키지가 있습니다.json 파일:
{
"name": "app",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@feathersjs/authentication-client": "^4.5.11",
"@feathersjs/feathers": "^4.5.11",
"@feathersjs/socketio-client": "^4.5.11",
"@vue/composition-api": "^1.1.3",
"core-js": "^3.6.5",
"feathers-hooks-common": "^5.0.6",
"socket.io-client": "^2.4.0",
"feathers-vuex": "^3.16.0",
"vue": "^2.6.11",
"vue-router": "^3.2.0",
"vue-spinner": "^1.0.4",
"vuex": "^3.4.0",
"vuex-persistedstate": "^4.0.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"vue-template-compiler": "^2.6.11"
}
}
로그인 기능:
methods: {
...mapActions('auth', ['authenticate']),
login() {
var email = this.$refs.emailInput.value
var password = this.$refs.passInput.value
this.authenticate({strategy: 'local', email, password})
.then(() => this.$router.push({name: 'Dashboard'}))
.catch((err) => {
let type = err.className
err = Object.assign({}, err)
err.message =
type === 'not-authenticated'
? 'Incorrect email or password'
: 'An error prevented login'
console.error(err.message)
})
}
}
당신의 시간을 절약할 수 있는 아주 좋은 프로젝트가 있습니다: 깃털과 부엑스를 쉽게 사용할 수 있습니다.
프로젝트 참조:https://vuex.feathersjs.com/
언급URL : https://stackoverflow.com/questions/68939831/feathers-vuex-my-auth-state-do-not-persist-despite-the-install-of-persiststate
반응형
'source' 카테고리의 다른 글
| 키업 Vuejs 2에 대한 입력 값 가져오기 (0) | 2022.08.17 |
|---|---|
| Vue 3 패키지 버전이 일치하지 않음 (0) | 2022.08.17 |
| 소켓 프로그래밍의 htons() 함수 (0) | 2022.08.17 |
| 'vue-test-utils' 및 'jest'를 사용한 'Created' 후크를 사용한 테스트 (0) | 2022.08.17 |
| 구체적으로, 말록의 결과를 캐스팅하는 것이 위험한 것은 무엇입니까? (0) | 2022.08.17 |