<template>
  <v-container>
    <Header />

    <LoginForm />
    <RegisterForm />
  </v-container>
</template>

<script>
import * as Cookies from 'js-cookie'
import axios from '@/plugins/axios'

import Header from '@/components/Header.vue'
import LoginForm from '@/components/forms/Login.vue'
import RegisterForm from '@/components/forms/Register.vue'

export default {
  name: 'Home',

  components: {
    Header,
    LoginForm,
    RegisterForm
  },

  computed: {
    session: () => Cookies.get('session')
  },

  mounted() {
    this.$nextTick(() => {
      axios
        .post('/user/login', {
          session: this.session
        })
        .then(response => {
          if (response.data.success) {
            this.$router.push({ name: 'usercp' })
          }
        })
    })
  }
}
</script>
