<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
  },

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