Token generation on client side (javascript).
This commit is contained in:
parent
c8ebf02e30
commit
aa1259b3dc
|
|
@ -4,7 +4,6 @@ import (
|
|||
"github.com/astaxie/beego"
|
||||
|
||||
"git.kingpenguin.tk/chteufleur/datahouse.git/models/user"
|
||||
"git.kingpenguin.tk/chteufleur/datahouse.git/models/utils"
|
||||
"git.kingpenguin.tk/chteufleur/datahouse.git/models/variables"
|
||||
|
||||
"net/http"
|
||||
|
|
@ -34,7 +33,6 @@ func (c *LoginController) Get() {
|
|||
return
|
||||
}
|
||||
|
||||
c.Data["token"] = utils.TokenGenerator(8)
|
||||
c.TplName = "login.tpl"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
<form id="loginForm" class="form-signin" action="/login" method="POST">
|
||||
<h2 class="form-signin-heading">Login</h2>
|
||||
<label for="inputEmail" class="sr-only">Email address</label>
|
||||
<input name="token" type="hidden" value="{{.token}}" />
|
||||
<input name="token" type="hidden" id="token-value" value="" />
|
||||
<input id="inputLogin" name="login" class="form-control" placeholder="Login" required autofocus />
|
||||
<label for="inputPassword" class="sr-only">Password</label>
|
||||
<input type="password" id="inputPassword" name="password" class="form-control" placeholder="Password" />
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
<input type="checkbox" value="remember-me"> Remember me
|
||||
</label>
|
||||
</div> -->
|
||||
<center><p>Token: {{.token}}</p></center>
|
||||
<center><p id="token-value-txt"></p></center>
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit">Laisse moi entrer</button>
|
||||
</form>
|
||||
|
||||
|
|
@ -53,8 +53,14 @@
|
|||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
|
||||
<script src="/static/js/jquery.sha256.min.js"></script>
|
||||
<script type="application/javascript">
|
||||
var rand = function() {
|
||||
return Math.random().toString(36).substr(2);
|
||||
}
|
||||
$("form").attr('action', window.location.pathname);
|
||||
$("#loginForm").submit(function() {
|
||||
var token = Math.random().toString(36).substr(2);
|
||||
$('#token-value').val(token);
|
||||
$('#token-value-txt').text("Token: "+token);
|
||||
$('#inputPassword').val($.sha256($('#inputPassword').val()));
|
||||
console.log("Password: "+$('#inputPassword').val());
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue