finish user registration / login
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{{define "login"}}
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<html>
|
||||
<head>
|
||||
<title>Login ~ PixelDrain</title>
|
||||
<meta charset="UTF-8"/>
|
||||
@@ -26,6 +26,8 @@
|
||||
<meta property="og:url" content="http://pixeldra.in/" />
|
||||
<meta property="og:image" content="/res/img/pixeldrain_big.png" />
|
||||
<meta property="og:image:type" content="image/png" />
|
||||
|
||||
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -33,26 +35,58 @@
|
||||
{{template "menu" .}}
|
||||
|
||||
<h1>Log in to your PixelDrain account</h1>
|
||||
<form action="/login" method="POST" class="highlight_dark border_top border_bottom">
|
||||
<div id="submit_result"></div>
|
||||
<form onSubmit="return submitForm();" class="highlight_dark border_top border_bottom">
|
||||
<table style="margin-left: auto; margin-right: auto;">
|
||||
<tr>
|
||||
<td>Username</td>
|
||||
<td><input name="username" type="text" value=""/></td>
|
||||
<td><input id="username" name="username" type="text" autocomplete="username" value=""/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Password</td>
|
||||
<td><input name="password" type="password"/></td>
|
||||
<td><input id="password" name="password" type="password" autocomplete="current-password"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2 style="text-align: right;"><input type="submit" value="Login"/></td>
|
||||
<td colspan=2 style="text-align: right;"><input type="submit" value="Login" class="button_highlight"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<br/>
|
||||
If you don't have a PixelDrain account, you can <a href="/register">register here</a>. No e-mail address required.<br/>
|
||||
If you don't have a PixelDrain account yet, you can <a href="/register">register here</a>. No e-mail address is required.<br/>
|
||||
{{template "footer"}}
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function submitForm(){
|
||||
var req = new XMLHttpRequest();
|
||||
req.onreadystatechange = function(){
|
||||
if (this.readyState === 4) {
|
||||
var response = JSON.parse(req.responseText);
|
||||
var resultDiv = document.getElementById("submit_result");
|
||||
if (response.success) {
|
||||
resultDiv.className = "border_top border_bottom highlight_green";
|
||||
resultDiv.innerHTML = 'Success! Proceeding to user portal...<br/>'
|
||||
+'<a href="/user">Click here if you are not redirected automatically</a>';
|
||||
window.location.href = "/user";
|
||||
} else {
|
||||
resultDiv.className = "border_top border_bottom highlight_red";
|
||||
resultDiv.innerHTML = response.message;
|
||||
}
|
||||
|
||||
console.log(response);
|
||||
}
|
||||
}
|
||||
|
||||
var data = new FormData();
|
||||
data.append("username", document.getElementById("username").value);
|
||||
data.append("password", document.getElementById("password").value);
|
||||
|
||||
req.open("POST", apiEndpoint+"/user/login", true);
|
||||
req.send(data);
|
||||
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
{{template "analytics"}}
|
||||
</body>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user