diff --git a/app/controllers/AlbumController.go b/app/controllers/AlbumController.go index 164d61f..be99982 100644 --- a/app/controllers/AlbumController.go +++ b/app/controllers/AlbumController.go @@ -2,11 +2,11 @@ package controllers import ( "github.com/revel/revel" -// "encoding/json" + // "encoding/json" "github.com/leanote/leanote/app/info" "gopkg.in/mgo.v2/bson" -// . "github.com/leanote/leanote/app/lea" -// "io/ioutil" + // . "github.com/leanote/leanote/app/lea" + // "io/ioutil" ) // Album controller @@ -19,7 +19,6 @@ func (c Album) GetAlbums() revel.Result { re := albumService.GetAlbums(c.GetUserId()) return c.RenderJson(re) } - func (c Album) DeleteAlbum(albumId string) revel.Result { re, msg := albumService.DeleteAlbum(c.GetUserId(), albumId) return c.RenderJson(info.Re{Ok: re, Msg: msg}) @@ -29,12 +28,12 @@ func (c Album) DeleteAlbum(albumId string) revel.Result { func (c Album) AddAlbum(name string) revel.Result { album := info.Album{ AlbumId: bson.NewObjectId(), - Name: name, - Seq: -1, - UserId: c.GetObjectUserId()} + Name: name, + Seq: -1, + UserId: c.GetObjectUserId()} re := albumService.AddAlbum(album) - if(re) { + if re { return c.RenderJson(album) } else { return c.RenderJson(false) @@ -44,4 +43,4 @@ func (c Album) AddAlbum(name string) revel.Result { // update alnum name func (c Album) UpdateAlbum(albumId, name string) revel.Result { return c.RenderJson(albumService.UpdateAlbum(albumId, c.GetUserId(), name)) -} \ No newline at end of file +} diff --git a/app/controllers/AuthController.go b/app/controllers/AuthController.go index b86137b..a13be7c 100644 --- a/app/controllers/AuthController.go +++ b/app/controllers/AuthController.go @@ -86,7 +86,8 @@ func (c Auth) Logout() revel.Result { // 体验一下 func (c Auth) Demo() revel.Result { email := configService.GetGlobalStringConfig("demoUsername") - pwd := configService.GetGlobalStringConfig("demoPassword"); + pwd := configService.GetGlobalStringConfig("demoPassword") + userInfo, err := authService.Login(email, pwd) if err != nil { return c.RenderJson(info.Re{Ok: false}) diff --git a/app/controllers/BlogController.go b/app/controllers/BlogController.go index e15973e..196ace2 100644 --- a/app/controllers/BlogController.go +++ b/app/controllers/BlogController.go @@ -265,10 +265,6 @@ func (c Blog) getCates(userBlog info.UserBlog) { } } - Log("cates") - LogJ(cates) - LogJ(catesTree); - c.RenderArgs["cates"] = cates c.RenderArgs["catesTree"] = catesTree } @@ -352,9 +348,10 @@ func (c Blog) blogCommon(userId string, userBlog info.UserBlog, userInfo info.Us // 得到主题信息 themeInfo := themeService.GetThemeInfo(userBlog.ThemeId.Hex(), userBlog.Style) c.RenderArgs["themeInfo"] = themeInfo - Log(">>") - Log(userBlog.Style) - Log(userBlog.ThemeId.Hex()) + +// Log(">>") +// Log(userBlog.Style) +// Log(userBlog.ThemeId.Hex()) return true, userBlog } diff --git a/app/controllers/IndexController.go b/app/controllers/IndexController.go index 7c5d290..cc7188c 100644 --- a/app/controllers/IndexController.go +++ b/app/controllers/IndexController.go @@ -21,13 +21,12 @@ func (c Index) Default() revel.Result { } // leanote展示页, 没有登录的, 或已登录明确要进该页的 func (c Index) Index() revel.Result { - c.SetUserInfo() c.RenderArgs["title"] = "leanote" c.RenderArgs["openRegister"] = configService.GlobalStringConfigs["openRegister"] - lang := c.SetLocale() + c.SetLocale() - return c.RenderTemplate("home/index_" + lang + ".html"); + return c.RenderTemplate("home/index.html"); } // 建议 diff --git a/app/controllers/UserController.go b/app/controllers/UserController.go index 0ac9beb..54358d5 100644 --- a/app/controllers/UserController.go +++ b/app/controllers/UserController.go @@ -29,8 +29,8 @@ func (c User) Account(tab int) revel.Result { // 修改用户名, 需要重置session func (c User) UpdateUsername(username string) revel.Result { - re := info.NewRe(); - if(c.GetUsername() == "demo") { + re := info.NewRe() + if c.GetUserId() == configService.GetGlobalStringConfig("demoUserId") { re.Msg = "cannotUpdateDemo" return c.RenderRe(re); } @@ -48,8 +48,8 @@ func (c User) UpdateUsername(username string) revel.Result { // 修改密码 func (c User) UpdatePwd(oldPwd, pwd string) revel.Result { - re := info.NewRe(); - if(c.GetUsername() == "demo") { + re := info.NewRe() + if c.GetUserId() == configService.GetGlobalStringConfig("demoUserId") { re.Msg = "cannotUpdateDemo" return c.RenderRe(re); } @@ -96,7 +96,7 @@ func (c User) ReSendActiveEmail() revel.Result { // 修改Email发送激活邮箱 func (c User) updateEmailSendActiveEmail(email, pwd string) revel.Result { re := info.NewRe() - if(c.GetUsername() == "demo") { + if c.GetUserId() == configService.GetGlobalStringConfig("demoUserId") { re.Msg = "cannotUpdateDemo" return c.RenderJson(re); } diff --git a/app/controllers/api/ApiAuthController.go b/app/controllers/api/ApiAuthController.go index f732462..6f16a37 100644 --- a/app/controllers/api/ApiAuthController.go +++ b/app/controllers/api/ApiAuthController.go @@ -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) -} \ No newline at end of file +} diff --git a/app/controllers/api/ApiNoteController.go b/app/controllers/api/ApiNoteController.go index 153e585..3c8feea 100644 --- a/app/controllers/api/ApiNoteController.go +++ b/app/controllers/api/ApiNoteController.go @@ -70,6 +70,7 @@ func (c ApiNote) GetNotes(notebookId string) revel.Result { func (c ApiNote) GetTrashNotes() revel.Result { _, notes := noteService.ListNotes(c.getUserId(), "", true, c.GetPage(), pageSize, defaultSortField, false, false) return c.RenderJson(noteService.ToApiNotes(notes)) + } // get Note diff --git a/app/views/errors/404.html b/app/views/errors/404.html index 5d38aa5..2b7c144 100644 --- a/app/views/errors/404.html +++ b/app/views/errors/404.html @@ -26,10 +26,10 @@