diff --git a/conf/app.conf b/conf/app.conf index 5123650..a5c256d 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -2,7 +2,9 @@ appname = beeblog httpport = 8082 runmode = dev +sessionon = true + EnableGzip = true EnableDocs = true -host = aiprose.com +host = aiprose.com \ No newline at end of file diff --git a/controllers/UserController.go b/controllers/UserController.go index 3ccc4a3..4d337f8 100644 --- a/controllers/UserController.go +++ b/controllers/UserController.go @@ -9,6 +9,7 @@ import ( "time" "strconv" "encoding/hex" + "fmt" ) type UserController struct { @@ -28,6 +29,9 @@ func (u *UserController) LoginPage() { //u.Ctx.WriteString("login page") u.TplName = "login.html" } +func (u *UserController) RegistPage() { + u.TplName = "regist.html" +} func (this *UserController) Login() { username := this.GetString("username") @@ -55,6 +59,9 @@ func (this *UserController) Login() { userpwd = hex.EncodeToString(h.Sum(nil)) if userpwd == user.UserPwd { this.Data["json"] = models.ReurnSuccess("") + this.SetSession("userid", user.Id) + tt := this.GetSession("userid").(int64) + fmt.Println(tt > 0) } else { this.Data["json"] = models.ReurnError("用户名或密码错误") } @@ -99,7 +106,7 @@ func (this *UserController) Regist() { user = &models.User{UserName: username, UserPwd: userpwd, Salt: salt} err := service.SaveUser(user) if err == nil { - this.Data["json"] = user + this.Data["json"] = models.ReurnSuccess("") } else { this.Data["json"] = models.ReurnError("注册失败") } diff --git a/data/beeblog.db b/data/beeblog.db index a2d24ee..40d3cd7 100644 Binary files a/data/beeblog.db and b/data/beeblog.db differ diff --git a/routers/UserRouter.go b/routers/UserRouter.go index dab2b3c..5bf1dd6 100644 --- a/routers/UserRouter.go +++ b/routers/UserRouter.go @@ -9,4 +9,5 @@ func init() { beego.Router("/login", &controllers.UserController{}, "get:LoginPage") beego.Router("/login", &controllers.UserController{}, "post:Login") beego.Router("/regist", &controllers.UserController{}, "post:Regist") + beego.Router("/regist", &controllers.UserController{}, "get:RegistPage") } diff --git a/static/css/login.css b/static/css/login.css index 61e1179..8e3a4e2 100644 --- a/static/css/login.css +++ b/static/css/login.css @@ -10,9 +10,26 @@ .login-root .input-container{ position: fixed; left: 65%; + top: 33px; background: url("/static/img/loginbg.png") no-repeat center top; } .login-root .input-container .input-root{ width: 370px; height: 500px; } +.login-root .input-container .input-root p { + font-size: 21px; + text-align: center; + padding-top: 195px; +} +.login-root .input-container .input-root .inputs-class{ + padding: 0 50px; +} +.login-root .input-container .input-root .inputs-class .input-class{ + height: 35px; + margin: 18px 0 +} +.login-root .input-container .input-root .inputs-class .input-class input{ + height: 35px !important; +} + diff --git a/views/login.html b/views/login.html index adab1ec..34e1d13 100644 --- a/views/login.html +++ b/views/login.html @@ -9,9 +9,53 @@

登录

+
+
+ 用户 + +
+
+ 密码 + +
+ +
+ \ No newline at end of file diff --git a/views/regist.html b/views/regist.html new file mode 100644 index 0000000..fa65b5c --- /dev/null +++ b/views/regist.html @@ -0,0 +1,64 @@ +{{template "header"}} +注册 - 个人随笔 + + + +
+{{template "nav" .}} +
+
+
+

注册

+
+
+ 用户 + +
+
+ 密码 + +
+ +
+
+
+
+
+ + + \ No newline at end of file