|
|
|
|
@ -1,44 +1,57 @@
|
|
|
|
|
<template>
|
|
|
|
|
<App>
|
|
|
|
|
<Header />
|
|
|
|
|
<div class="bg-secondary mx-auto mt-12 flex h-96 w-96 flex-col items-center justify-center gap-8 rounded-xl p-8">
|
|
|
|
|
<div class="flex w-full flex-col gap-2">
|
|
|
|
|
<label class="w-full text-[#b3b3b3]"> Email </label>
|
|
|
|
|
<input type="text"
|
|
|
|
|
class="bg-lightgray border-lightgray h-12 w-full rounded-md border p-4 text-lg placeholder:text-[#4f4f4f] focus:outline-none active:outline-none"
|
|
|
|
|
v-model="credential.email" placeholder="username" />
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex w-full flex-col gap-2">
|
|
|
|
|
<label class="w-full text-[#b3b3b3]"> Password </label>
|
|
|
|
|
<input type="password"
|
|
|
|
|
class="bg-lightgray border-lightgray h-12 w-full rounded-md border p-4 text-lg placeholder:text-[#4f4f4f] focus:outline-none active:outline-none"
|
|
|
|
|
v-model="credential.password" placeholder="password" />
|
|
|
|
|
</div>
|
|
|
|
|
<p class="cursor-pointer text-blue-500 underline" @click="toggleSignup()">
|
|
|
|
|
{{
|
|
|
|
|
isSignup
|
|
|
|
|
? 'Already have an account? Login'
|
|
|
|
|
: "Don't have an account? Sign up"
|
|
|
|
|
}}
|
|
|
|
|
</p>
|
|
|
|
|
<button class="w-fit rounded-lg bg-blue-500 py-4 px-8" v-on="isSignup
|
|
|
|
|
? { click: () => signUp() }
|
|
|
|
|
: { click: () => signIn() }
|
|
|
|
|
">
|
|
|
|
|
{{ isSignup ? 'Sign Up' : 'Login' }}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</App>
|
|
|
|
|
<App>
|
|
|
|
|
<Header />
|
|
|
|
|
<el-card>
|
|
|
|
|
<div
|
|
|
|
|
class="mx-auto my-4 flex h-80 w-96 flex-col items-center justify-center gap-8 rounded-xl p-8">
|
|
|
|
|
<div class="flex w-full flex-col gap-2">
|
|
|
|
|
<label class="w-full text-[#b3b3b3]"> Email </label>
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="credential.email"
|
|
|
|
|
placeholder="Username"
|
|
|
|
|
clearable
|
|
|
|
|
class="h-12" />
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex w-full flex-col gap-2">
|
|
|
|
|
<label class="w-full text-[#b3b3b3]"> Password </label>
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="credential.password"
|
|
|
|
|
type="password"
|
|
|
|
|
placeholder="Password"
|
|
|
|
|
show-password
|
|
|
|
|
class="h-12" />
|
|
|
|
|
</div>
|
|
|
|
|
<p
|
|
|
|
|
class="cursor-pointer text-blue-500 underline"
|
|
|
|
|
@click="toggleSignup()">
|
|
|
|
|
{{
|
|
|
|
|
isSignup
|
|
|
|
|
? 'Already have an account? Login'
|
|
|
|
|
: "Don't have an account? Sign up"
|
|
|
|
|
}}
|
|
|
|
|
</p>
|
|
|
|
|
<button
|
|
|
|
|
class="w-fit rounded-lg bg-blue-500 px-8 py-4"
|
|
|
|
|
v-on="
|
|
|
|
|
isSignup
|
|
|
|
|
? { click: () => signUp() }
|
|
|
|
|
: { click: () => signIn() }
|
|
|
|
|
">
|
|
|
|
|
{{ isSignup ? 'Sign Up' : 'Login' }}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</el-card>
|
|
|
|
|
</App>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
definePageMeta({
|
|
|
|
|
middleware: ['auth'],
|
|
|
|
|
middleware: ['auth'],
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const credential = reactive({
|
|
|
|
|
email: '',
|
|
|
|
|
password: '',
|
|
|
|
|
email: '',
|
|
|
|
|
password: '',
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
@ -46,27 +59,27 @@ const user = useSupabaseUser()
|
|
|
|
|
const isSignup = ref<Boolean>(false)
|
|
|
|
|
|
|
|
|
|
const toggleSignup = () => {
|
|
|
|
|
isSignup.value = !isSignup.value
|
|
|
|
|
isSignup.value = !isSignup.value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const signUp = async () => {
|
|
|
|
|
const error = userSignUp(credential.email, credential.password)
|
|
|
|
|
const error = userSignUp(credential.email, credential.password)
|
|
|
|
|
|
|
|
|
|
console.log('error', error)
|
|
|
|
|
console.log('error', error)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const signIn = async () => {
|
|
|
|
|
const error = userSignIn(credential.email, credential.password)
|
|
|
|
|
const error = userSignIn(credential.email, credential.password)
|
|
|
|
|
|
|
|
|
|
console.log('error', error)
|
|
|
|
|
console.log('error', error)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => user.value,
|
|
|
|
|
() => {
|
|
|
|
|
if (user.value) {
|
|
|
|
|
router.push('/notes')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
() => user.value,
|
|
|
|
|
() => {
|
|
|
|
|
if (user.value) {
|
|
|
|
|
router.push('/notes')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
</script>
|
|
|
|
|
|