From 335474853d70be8fd60d18961a5d15eba538656c Mon Sep 17 00:00:00 2001 From: yirenyishi Date: Sun, 18 Nov 2018 21:16:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E7=99=BB=E5=BD=95=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/app.conf | 4 ++- controllers/UserController.go | 9 ++++- data/beeblog.db | Bin 32768 -> 32768 bytes routers/UserRouter.go | 1 + static/css/login.css | 17 +++++++++ views/login.html | 44 +++++++++++++++++++++++ views/regist.html | 64 ++++++++++++++++++++++++++++++++++ 7 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 views/regist.html 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 a2d24eecfec147e4ea8899e845d5767282f21127..40d3cd7e24b938b20e4675e4a6b3a65fdabbce60 100644 GIT binary patch delta 743 zcmZ9KziO0G5XHaUFAK@S?iYm+LIjgekgPLv|IW77!B@!rH;od(-4s^4t(`tVK*Sd? zX?=!(on62#*jszojgaJWi_0+ZJLlZ9T=tjC{>S~^;io4rdxzgnzCInc-F4Ib>2A8~ z%SYQky5VNq?)1)P<=x=&=EeT@crdzXx)0ss@%i}K=%Vg?9xdjBakG1TJZeVuY>r;d z%WO^|s6;wO zGN6ny53n@Ve&P*V!dq%PZg%c_UCgsW&0d&_C}&WT@+FvD-9>L>&Ls;ZXMA+QgLWLa zt|co%F25LP}miaahxhTj(54x6SKbXTh;{_1{qSKaU0 nwC^2lwY$B4?Hc@l;l^ey=xWvu+r8d8nEqC~x3$*#<>cTmf_b>7 delta 55 zcmZo@U}|V!njp<6Gf~EwQD$Sp5_t|L{+A5=-}ql{78JP4zxk!Uw7_N-fj|6=T$>pM Kn1SqsKk@+K-4RIu 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