Merge register and login into one

This commit is contained in:
Bruno Rybársky 2024-02-03 18:06:15 +01:00
parent e3901499cd
commit 5c2d906fb0
2 changed files with 64 additions and 67 deletions

@ -1,7 +1,7 @@
<script>
function login() {
const email = document.getElementById("email").value;
const password = document.getElementById("password").value;
const email = document.getElementById("login_email").value;
const password = document.getElementById("login_password").value;
doLogin(email, password);
}
@ -13,20 +13,75 @@
doAccountAction(data, "Login Successful!", "Login failed. Please check your credentials.");
}
function register() {
const firstName = document.getElementById("register_firstName").value;
const lastName = document.getElementById("register_lastName").value;
const nickname = document.getElementById("register_nickname").value;
const email = document.getElementById("register_email").value;
const password = document.getElementById("register_password").value;
const minecraftNick = document.getElementById("register_minecraftNick").value;
const activationToken = document.getElementById("register_activationToken").value;
const data = new URLSearchParams();
data.append("action", "register");
data.append("firstname", firstName);
data.append("lastname", lastName);
data.append("nickname", nickname);
data.append("email", email);
data.append("password", password);
data.append("minecraft_nick", minecraftNick);
data.append("activation_token", activationToken);
doRegister(data);
}
function doRegister(requestData) {
doAccountAction(requestData, "Registration Successful!", "Registration failed.");
}
</script>
<!-- Centralized Status Message -->
<p id="StatusMessage"></p>
<div class="form-container" id="loginForm">
<h1>Login</h1>
<form>
<label for="email">Email:</label>
<input type="text" id="email" name="email" required>
<label for="login_email">Email:</label>
<input type="text" id="login_email" name="email" required><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<label for="login_password">Password:</label>
<input type="password" id="login_password" name="password" required><br>
<button type="button" onclick="login()">Login</button>
</form>
</form><hr>
</div>
<!-- Centralized Status Message -->
<p id="StatusMessage"></p>
<div class="form-container" id="register_Form">
<h1>Register</h1>
<form>
<label for="register_firstName">First Name:</label>
<input type="text" id="register_firstName" name="firstName" required><br>
<label for="register_lastName">Last Name:</label>
<input type="text" id="register_lastName" name="lastName" required><br>
<label for="register_nickname">Nickname:</label>
<input type="text" id="register_nickname" name="nickname" required><br>
<label for="register_email">Email:</label>
<input type="text" id="register_email" name="email" required><br>
<label for="register_password">Password:</label>
<input type="password" id="register_password" name="password" required><br>
<label for="register_minecraftNick">Minecraft Nick:</label>
<input type="text" id="register_minecraftNick" name="minecraftNick" required><br>
<label for="register_activationToken">Activation Token:</label>
<input type="text" id="register_activationToken" name="activationToken" required><br>
<button type="button" onclick="register()">Register</button>
</form>
</div>

@ -1,58 +0,0 @@
<script>
function register() {
const firstName = document.getElementById("firstName").value;
const lastName = document.getElementById("lastName").value;
const nickname = document.getElementById("nickname").value;
const email = document.getElementById("email").value;
const password = document.getElementById("password").value;
const minecraftNick = document.getElementById("minecraftNick").value;
const activationToken = document.getElementById("activationToken").value;
const data = new URLSearchParams();
data.append("action", "register");
data.append("firstname", firstName);
data.append("lastname", lastName);
data.append("nickname", nickname);
data.append("email", email);
data.append("password", password);
data.append("minecraft_nick", minecraftNick);
data.append("activation_token", activationToken);
doRegister(data);
}
function doRegister(requestData) {
doAccountAction(requestData, "Registration Successful!", "Registration failed.");
}
</script>
<div class="form-container" id="registerForm">
<h1>Register</h1>
<form>
<label for="firstName">First Name:</label>
<input type="text" id="firstName" name="firstName" required>
<label for="lastName">Last Name:</label>
<input type="text" id="lastName" name="lastName" required>
<label for="nickname">Nickname:</label>
<input type="text" id="nickname" name="nickname" required>
<label for="email">Email:</label>
<input type="text" id="email" name="email" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<label for="minecraftNick">Minecraft Nick:</label>
<input type="text" id="minecraftNick" name="minecraftNick" required>
<label for="activationToken">Activation Token:</label>
<input type="text" id="activationToken" name="activationToken" required>
<button type="button" onclick="register()">Register</button>
</form>
</div>
<!-- Centralized Status Message -->
<p id="StatusMessage"></p>