added token to local storage

main
Ayush Mukherjee 4 years ago
parent d8ce30df85
commit 24b90f6293

@ -2,9 +2,11 @@ import { reactive, readonly } from 'vue'
import axios from 'axios' import axios from 'axios'
import { handleMsg, sendSub } from './utils/websocket' import { handleMsg, sendSub } from './utils/websocket'
const token = localStorage.getItem('token')
const state = reactive({ const state = reactive({
name: '', name: '',
token: '', token: token || '',
session: '', session: '',
loggedIn: false, loggedIn: false,
ws: null, ws: null,
@ -21,7 +23,7 @@ const state = reactive({
const methods = { const methods = {
authenticate: async (token) => { authenticate: async (token) => {
console.log(token) localStorage.setItem('token', token)
return axios.post('http://178.79.128.135:5000/api/v1', { return axios.post('http://178.79.128.135:5000/api/v1', {
token, token,
}) })

@ -92,8 +92,6 @@ export default {
window.ipcRenderer.on('test', (e, msg) => { window.ipcRenderer.on('test', (e, msg) => {
const data = JSON.parse(msg) const data = JSON.parse(msg)
// const games = m.hasOwnProperty('games') ? m.games.push(data.game) : [data.game]
update('matches', data.id, { update('matches', data.id, {
started: data.started, started: data.started,
done: data.done, done: data.done,

@ -1,6 +1,6 @@
<template> <template>
<div class="bg-gray-200 w-screen h-screen mx-auto py-10 flex flex-col justify-center items-center"> <div class="bg-gray-200 w-screen h-screen mx-auto py-10 flex flex-col justify-center items-center">
<h1 class="text-2xl uppercase text-red-600 font-black text-center">APL Slapdash</h1> <h1 class="text-2xl uppercase text-red-500 font-black text-center">Slapdash</h1>
<h2 class="my-4 text-lg">Welcome to Slapdash!</h2> <h2 class="my-4 text-lg">Welcome to Slapdash!</h2>
<p class="my-8">Please enter your token to continue</p> <p class="my-8">Please enter your token to continue</p>
<div class="input w-96 flex flex-col justify-center items-center"> <div class="input w-96 flex flex-col justify-center items-center">
@ -18,7 +18,7 @@ export default {
setup() { setup() {
const store = inject('store') const store = inject('store')
const disable = ref(false) const disable = ref(false)
const token = ref('') const token = ref(store.state.token)
const router = useRouter() const router = useRouter()
const doAuth = async () => { const doAuth = async () => {

Loading…
Cancel
Save