mirror of
https://github.com/PretendoNetwork/website.git
synced 2026-09-30 20:46:57 -05:00
made auth forms usuable for end user
This commit is contained in:
@@ -11,16 +11,44 @@ function postAjax(url, data, success) {
|
||||
return xhr;
|
||||
}
|
||||
|
||||
function showErrorPopup(errorText) {
|
||||
console.log(errorText)
|
||||
}
|
||||
|
||||
function login() {
|
||||
var xhr = postAjax('/api/v1/login', {
|
||||
email: document.getElementById('email_input').value,
|
||||
password: document.getElementById('password_input').value
|
||||
});
|
||||
xhr.onload = function () {
|
||||
console.log(xhr.responseText);
|
||||
if (xhr.responseText.charAt(0) !== "{") {
|
||||
return showErrorPopup('Whoops, something went wrong. Try again later.');
|
||||
}
|
||||
response = JSON.parse(xhr.responseText);
|
||||
if (response.success === true) {
|
||||
location.pathname = '/pnid/dashboard';
|
||||
} else if (response.errors) {
|
||||
showErrorPopup(response.errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function register() {
|
||||
var xhr = postAjax('/api/v1/register', {
|
||||
email: document.getElementById('email_input').value,
|
||||
username: document.getElementById('username_input').value,
|
||||
password: document.getElementById('password_input').value,
|
||||
confirm_password: document.getElementById('password_confirm_input').value
|
||||
});
|
||||
xhr.onload = function () {
|
||||
if (xhr.responseText.charAt(0) !== "{") {
|
||||
return showErrorPopup('Whoops, something went wrong. Try again later.');
|
||||
}
|
||||
response = JSON.parse(xhr.responseText);
|
||||
if (response.success === true) {
|
||||
login();
|
||||
} else if (response.errors) {
|
||||
showErrorPopup(response.errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,13 +12,13 @@
|
||||
<div class="content">
|
||||
<p class="txt-highlight">ERROR</p>
|
||||
<h1 class="txt-title small">{{ locale.login.card.title }}</h1>
|
||||
<form action="/api/v1/sendmessage" method="POST">
|
||||
<form method="POST">
|
||||
<label for="email">{{ locale.login.card.email_text }}</label>
|
||||
<input type="text" class="hasLabel" id="email_input" name="email">
|
||||
<label for="email">{{ locale.login.card.password_text }}</label>
|
||||
<input type="password" class="hasLabel" id="password_input" name="password">
|
||||
</form>
|
||||
<button class="btn btnMargin" onclick="login()">{{ locale.login.card.button_text }}</button>
|
||||
<button class="btn btnMargin" onclick="login();">{{ locale.login.card.button_text }}</button>
|
||||
<p class="lowText">ERROR <a href="#">ERROR</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<div class="content">
|
||||
<p class="txt-highlight">{{ locale.register.card.caption }}</p>
|
||||
<h1 class="txt-title small">{{ locale.register.card.title }}</h1>
|
||||
<form action="/api/v1/register" method="POST">
|
||||
<form method="POST">
|
||||
<label for="email">{{ locale.register.card.email_text }}</label>
|
||||
<input type="text" class="hasLabel" id="email_input" name="email">
|
||||
<label for="username">{{ locale.register.card.username_text }}</label>
|
||||
@@ -25,9 +25,8 @@
|
||||
<input type="password" class="hasLabel" id="password_confirm_input" name="confirm_password">
|
||||
|
||||
<div class="g-recaptcha" data-sitekey="{{ recaptcha_sitekey }}"></div>
|
||||
|
||||
<button type="submit" class="btn btnMargin">ERROR</button>
|
||||
</form>
|
||||
<button class="btn btnMargin" onclick="register()">ERROR</button>
|
||||
<p class="lowText">ERROR <a href="#">ERROR</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user