leanote v1.1 release

This commit is contained in:
lealife
2015-10-10 17:23:27 +08:00
parent a4d9d8e0d3
commit cb7e272bbe
15 changed files with 117 additions and 402 deletions

View File

@ -23,16 +23,16 @@ type ApiAuth struct {
// 失败返回 {Ok: false, Msg: ""}
func (c ApiAuth) Login(email, pwd string) revel.Result {
var msg = ""
userInfo, err := authService.Login(email, pwd)
if err != nil {
// 登录错误, 则错误次数++
msg = "wrongUsernameOrPassword"
} else {
if err == nil {
token := bson.NewObjectId().Hex()
sessionService.SetUserId(token, userInfo.UserId.Hex())
return c.RenderJson(info.AuthOk{Ok: true, Token: token, UserId: userInfo.UserId, Email: userInfo.Email, Username: userInfo.Username})
}
} else {
// 登录错误, 则错误次数++
msg = "wrongUsernameOrPassword"
}
return c.RenderJson(info.ApiRe{Ok: false, Msg: c.Message(msg)})
}
@ -66,4 +66,4 @@ func (c ApiAuth) Register(email, pwd string) revel.Result {
// 注册
re.Ok, re.Msg = authService.Register(email, pwd, "")
return c.RenderJson(re)
}
}