You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OneAuth/ui/page/auth/register.html

81 lines
2.3 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Register Page">
<title>{{ $t('auth.register') }}</title>
<style>
.register-title {
font-size: 24px;
font-weight: bold;
text-align: center;
margin-bottom: 20px;
color: var(--color-primary);
}
.links {
margin-top: 15px;
text-align: center;
font-size: 14px;
}
.links a {
color: var(--color-primary);
text-decoration: none;
}
.error-msg {
color: var(--color-danger);
text-align: center;
margin-bottom: 10px;
font-size: 14px;
}
</style>
</head>
<body>
<h2 class="register-title">{{ $t('auth.register') }}</h2>
<div v-if="error" class="error-msg">{{ error }}</div>
<form @submit.prevent="handleRegister" style="display: grid; gap: 16px;">
<v-input :label="$t('auth.username')" v:value="username" required></v-input>
<v-input :label="$t('auth.email')" type="email" v:value="email" required></v-input>
<v-input :label="$t('auth.password')" type="password" v:value="password" required></v-input>
<v-input :label="$t('common.confirm') + ' ' + $t('auth.password')" type="password" v:value="confirmPassword" required></v-input>
<v-btn type="submit" color="primary" block style="margin-top: 8px;">{{ $t('auth.register') }}</v-btn>
</form>
<div class="links">
<a href="/login">{{ $t('auth.login') }}</a>
</div>
</body>
<script setup>
username = "";
email = "";
password = "";
confirmPassword = "";
error = "";
handleRegister = async () => {
error = "";
if (password !== confirmPassword) {
error = "Passwords do not match";
return;
}
try {
await $axios.post('/api/auth/register', {
username: username,
email: email,
password: password
});
$message.success($t('auth.register_success'));
$router.push('/login');
} catch (err) {
console.error(err);
error = err.message || "Registration failed";
}
};
</script>
</html>