diff options
author | FuXiaoHei <fuxiaohei@hexiaz.com> | 2014-03-06 21:33:17 +0800 |
---|---|---|
committer | FuXiaoHei <fuxiaohei@hexiaz.com> | 2014-03-06 21:33:17 +0800 |
commit | 4b912b9ae6e087271c0c98b6e444384555ea3e84 (patch) | |
tree | 1b5f0826c82aec2cb03d1f2fd86af2bd8bf69da6 /routers | |
parent | e878bfb80f52c334a18fbf7b18f79359f7d373af (diff) | |
download | gitea-4b912b9ae6e087271c0c98b6e444384555ea3e84.tar.gz gitea-4b912b9ae6e087271c0c98b6e444384555ea3e84.zip |
signed-in dashboard and navbar changes
Diffstat (limited to 'routers')
-rw-r--r-- | routers/dashboard.go | 13 | ||||
-rw-r--r-- | routers/user/user.go | 21 |
2 files changed, 30 insertions, 4 deletions
diff --git a/routers/dashboard.go b/routers/dashboard.go index 8c370027bc..c154623820 100644 --- a/routers/dashboard.go +++ b/routers/dashboard.go @@ -5,11 +5,16 @@ package routers import ( + "github.com/gogits/gogs/modules/base" + "github.com/gogits/gogs/routers/user" "github.com/martini-contrib/render" + "github.com/martini-contrib/sessions" ) -func Dashboard(r render.Render) { - r.HTML(200, "dashboard", map[string]interface{}{ - "Title": "Dashboard", - }) +func Home(r render.Render, data base.TmplData, session sessions.Session) { + if user.IsSignedIn(session) { + user.Dashboard(r, data, session) + return + } + r.HTML(200, "home", nil) } diff --git a/routers/user/user.go b/routers/user/user.go index ccbbd01b44..9e4e30bbb6 100644 --- a/routers/user/user.go +++ b/routers/user/user.go @@ -18,6 +18,20 @@ import ( "github.com/gogits/gogs/utils/log" ) +func Dashboard(r render.Render, data base.TmplData, session sessions.Session) { + if !IsSignedIn(session) { + // todo : direct to logout + r.Redirect("/") + return + } + data["IsSigned"] = true + data["SignedUserId"] = SignedInId(session) + data["SignedUserName"] = SignedInName(session) + + data["Title"] = "Dashboard" + r.HTML(200, "user/dashboard", data) +} + func Profile(r render.Render) { r.HTML(200, "user/profile", map[string]interface{}{ "Title": "Username", @@ -65,10 +79,16 @@ func SignedInUser(session sessions.Session) *models.User { } func SignIn(req *http.Request, r render.Render, session sessions.Session) { + // if logged, do not show login page + if IsSignedIn(session) { + r.Redirect("/") + return + } var ( errString string account string ) + // if post, do login action if req.Method == "POST" { account = req.FormValue("account") user, err := models.LoginUserPlain(account, req.FormValue("passwd")) @@ -82,6 +102,7 @@ func SignIn(req *http.Request, r render.Render, session sessions.Session) { // login fail errString = fmt.Sprintf("%v", err) } + // if get or error post, show login page r.HTML(200, "user/signin", map[string]interface{}{ "Title": "Log In", "Error": errString, |