27 lines
722 B
Vue
27 lines
722 B
Vue
<script setup>
|
|
import RegisterForm from '../components/Register/RegisterForm.vue';
|
|
import { useRouter } from 'vue-router';
|
|
import { register } from '../lib/api';
|
|
|
|
const router = useRouter();
|
|
|
|
const handleNewUser = async ({ username, password, hcaptchaResponse }) => {
|
|
try {
|
|
const response = await register(username, password, hcaptchaResponse);
|
|
|
|
alert(response.message || 'Registration successful! Please log in.');
|
|
// Redirect to login page
|
|
router.push('/login');
|
|
} catch (error) {
|
|
console.error("Registration error:", error);
|
|
alert("Registration error: " + error);
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<div class="ts-app-center">
|
|
<RegisterForm @new-user="handleNewUser" />
|
|
</div>
|
|
</template>
|