You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

home.go 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package routers
  5. import (
  6. "github.com/gogits/gogs/modules/base"
  7. "github.com/gogits/gogs/modules/middleware"
  8. "github.com/gogits/gogs/modules/setting"
  9. "github.com/gogits/gogs/routers/user"
  10. )
  11. const (
  12. HOME base.TplName = "home"
  13. )
  14. func Home(ctx *middleware.Context) {
  15. if ctx.IsSigned {
  16. if !ctx.User.IsActive && setting.Service.RegisterEmailConfirm {
  17. ctx.Data["Title"] = ctx.Tr("auth.active_your_account")
  18. ctx.HTML(200, user.ACTIVATE)
  19. } else {
  20. user.Dashboard(ctx)
  21. }
  22. return
  23. }
  24. // Check auto-login.
  25. uname := ctx.GetCookie(setting.CookieUserName)
  26. if len(uname) != 0 {
  27. ctx.Redirect("/user/login")
  28. return
  29. }
  30. if setting.OauthService != nil {
  31. ctx.Data["OauthEnabled"] = true
  32. ctx.Data["OauthService"] = setting.OauthService
  33. }
  34. ctx.Data["PageIsHome"] = true
  35. ctx.HTML(200, HOME)
  36. }
  37. func NotFound(ctx *middleware.Context) {
  38. ctx.Data["Title"] = "Page Not Found"
  39. ctx.Handle(404, "home.NotFound", nil)
  40. }