user.js 800 B

1234567891011121314151617181920212223242526272829303132333435
  1. import UserService from "@/services/UserService";
  2. // const localStorageToken = JSON.parse(localStorage.getItem("accessToken"))
  3. export const state = () => ({
  4. accessToken: '',
  5. auth: false
  6. });
  7. export const mutations = {
  8. SET_USER_TOKEN (state, token) {
  9. state.accessToken = token
  10. state.auth = true
  11. }
  12. };
  13. export const actions = {
  14. login({ commit }, params) {
  15. return UserService.login(params).then((accesToken) => {
  16. })
  17. },
  18. registration({ commit }, params) {
  19. return UserService.registration(params)
  20. .then((response) => {
  21. localStorage.setItem('accessToken', response.toString())
  22. commit("SET_USER_TOKEN", response)
  23. return response
  24. })
  25. },
  26. };
  27. export const getters = {
  28. };