Can anyone tell me how to make a secure login system in a web app
using GO!?
I'm using web.go (
http://www.getwebgo.com/) and tring to creat a small
website (guest book example :D)
But I not sure how to log the user in! :D
################# CODE ###################
package main
import (
"web"
)
var logeg = false;
var username = '';
func mainpage(val string) string {
if(!loged){
html ='
<html>
<head><title>Test</title></head>
<body>
<form method="post" action="/login" enctype="multipart/form-data">
ID:<input type='text" name="id" /><br />
PASS:<input type='text" name="pass" /><br />
<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>
';
}else{
html ='
<html>
<head><title>Test</title></head>
<body>
Hi '+username+'!
</body>
</html>
';
}
return html;
}
func login(ctx *web.Context) string {
//now is some id and pass, in fact maybe I will use SQL of XML to
store it
id1, pass1 := "me", "123";
id2, pass2 := "you", "456";
/*
what should i do next!?
I know I can use Cookies
But is there anything else!?
How can I change "loged" value to true!?
I you can, please show me the best secure way!
*/
}
func main() {
web.Get("/(.*)", mainpage)
web.Post("/login", login)
web.Run("
0.0.0.0:9999")
}
##########################################