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.

auth.go 527B

12345678910111213141516171819202122232425262728
  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 middleware
  5. import (
  6. "github.com/codegangsta/martini"
  7. )
  8. func SignInRequire(redirect bool) martini.Handler {
  9. return func(ctx *Context) {
  10. if !ctx.IsSigned {
  11. if redirect {
  12. ctx.Render.Redirect("/")
  13. }
  14. return
  15. }
  16. }
  17. }
  18. func SignOutRequire() martini.Handler {
  19. return func(ctx *Context) {
  20. if ctx.IsSigned {
  21. ctx.Render.Redirect("/")
  22. }
  23. }
  24. }