HEX
Server: Apache
System: Linux srv-plesk28.ps.kz 5.14.0-284.18.1.el9_2.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jun 29 17:06:27 EDT 2023 x86_64
User: greencl1 (10085)
PHP: 8.1.33
Disabled: apache_setenv,dl,eval,exec,openlog,passthru,pcntl_exec,pcntl_fork,popen,posix_getpwuid,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,socket_create,socket_create_listen,socket_create_pair,syslog,system,socket_listen,stream_socket_server
Upload Files
File: /var/www/vhosts/greenclinic.kz/test.greenclinic.kz/src/store/modules/auth.js
import router from '../../router'
import axios from 'axios'

export default {
    state: {
        token: [],
        redirect: null,
    },
    mutations: {
        SIGN_IN: (state, token) => {
            state.token.push(token)
        },
        REDIRECT: (state, type) => {
            state.redirect = type
        },
        LOGOUT: (state, token) => {
            if (router.history.current.path !== '/') {
                router.push('/')
            } 
            axios({ 
                method: 'post',
                url: process.env.VUE_APP_API_URL + process.env.VUE_APP_API_VERSION + 'auth/logout',
                headers: {
                    'Authorization': `Bearer ${token}` 
                },
                data: {}
            })
            .then((response) => {
                if (response.status == 200) {
                    state.token = []
                } 
            })
            .then(() => {
                localStorage.clear()
                location.reload()
            })
            .catch((error) => {
                console.log(error);
            });    
        }
    },
    actions: {
        SIGN_IN_USER ({commit}, data__profile) {
            commit('SIGN_IN', data__profile.token)
            commit('REDIRECT', data__profile.type)
            this.dispatch('USER_DATA')
        },
        SIGN_OUT_USER ({commit}) {
            commit('LOGOUT', this.getters.GET_TOKEN[0])
        },
    },
    getters: {
        GET_TOKEN(state) {
            return state.token
        },
        GET_REDIRECT(state) {
            return state.redirect
        },
    },
}