Commit c8867f30 authored by Patrick Ade's avatar Patrick Ade
Browse files

Merge branch 'backup_ade'

parents a9d58172 e6e9197f
<script setup lang="ts">
import TheWelcome from '../components/TheWelcome.vue'
</script>
<template>
<main>
<TheWelcome />
</main>
</template>
<script lang="ts">
import { useAuthStore } from '../stores/auth'
export default {
setup() {
const authStore = useAuthStore()
return {
authStore,
}
},
data() {
return {
email: '',
password: '',
error: '',
}
},
methods: {
async login() {
await this.authStore.login(this.email, this.password, this.$router)
if (!this.authStore.isAuthenticated) {
this.error = 'Login failed. Please check your credentials.'
}
},
resetError() {
this.error = ''
},
},
}
</script>
<template>
<div class="login">
<h1>Login</h1>
<form @submit.prevent="login">
<div>
<label for="email"> Email: </label>
<input v-model="email" id="email" type="text" required @input="resetError" />
</div>
<div>
<label for="password"> Password: </label>
<input
v-model="password"
id="password"
type="password"
required
@input="resetError"
/>
</div>
<button type="submit">Login</button>
</form>
<p v-if="error" class="error">{{ error }}</p>
</div>
<p v-if="error" class="error">{{ error }}</p>
</template>
<script lang="ts">
import { getCSRFToken } from '../stores/auth'
export default {
data() {
return {
email: '',
password: '',
error: '',
success: '',
}
},
methods: {
async register() {
try {
const response = await fetch('http://localhost:8000/api/register', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': getCSRFToken(),
},
body: JSON.stringify({
email: this.email,
password: this.password,
}),
credentials: 'include',
})
const data = await response.json()
if (response.ok) {
this.success = 'Registration successful! Please log in.'
setTimeout(() => {
this.$router.push('/login')
}, 1000)
} else {
this.error = data.error || 'Registration failed'
}
} catch (err) {
this.error = 'An error occurred during registration: ' + err
}
},
},
}
</script>
<template>
<div>
<h2>Register</h2>
<form @submit.prevent="register">
<div>
<label for="email"> Email: </label>
<input v-model="email" id="email" type="email" required />
</div>
<div>
<label for="password"> Password: </label>
<input v-model="password" id="password" type="password" required />
</div>
<button type="submit">Register</button>
</form>
<p v-if="error">{{ error }}</p>
<p v-if="success">{{ success }}</p>
</div>
</template>
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"exclude": ["src/**/__tests__/*"],
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"paths": {
"@/*": ["./src/*"]
}
}
}
{
"files": [],
"references": [
{
"path": "./tsconfig.node.json"
},
{
"path": "./tsconfig.app.json"
}
]
}
{
"extends": "@tsconfig/node22/tsconfig.json",
"include": [
"vite.config.*",
"vitest.config.*",
"cypress.config.*",
"nightwatch.conf.*",
"playwright.config.*",
"eslint.config.*"
],
"compilerOptions": {
"noEmit": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"module": "ESNext",
"moduleResolution": "Bundler",
"types": ["node"]
}
}
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
// https://vite.dev/config/
export default defineConfig({
plugins: [vue()],
server: {
host: true // oder host: '0.0.0.0'
}
plugins: [
vue(),
vueDevTools(),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
},
},
})
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment