From 9330c943cd17152c5aca1619f6b87382e3800732 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Wed, 18 Nov 2015 23:52:09 -0500 Subject: work on #1891 --- modules/middleware/auth.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'modules/middleware/auth.go') diff --git a/modules/middleware/auth.go b/modules/middleware/auth.go index 823e457a..2dd9b0fd 100644 --- a/modules/middleware/auth.go +++ b/modules/middleware/auth.go @@ -109,6 +109,18 @@ func Toggle(options *ToggleOptions) macaron.Handler { } } + // Try auto-signin when not signed in. + if !ctx.IsSigned { + succeed, err := AutoSignIn(ctx) + if err != nil { + ctx.Handle(500, "AutoSignIn", err) + return + } else if succeed { + ctx.Redirect(ctx.Req.URL.Path) + return + } + } + if options.AdminRequire { if !ctx.User.IsAdmin { ctx.Error(403) -- cgit v1.2.3 From ee686f62315006df6d85ad0f74dfc6119b920469 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 19 Nov 2015 00:22:16 -0500 Subject: minor fix on auto sign in --- modules/middleware/auth.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/middleware/auth.go') diff --git a/modules/middleware/auth.go b/modules/middleware/auth.go index 2dd9b0fd..4b953157 100644 --- a/modules/middleware/auth.go +++ b/modules/middleware/auth.go @@ -110,13 +110,13 @@ func Toggle(options *ToggleOptions) macaron.Handler { } // Try auto-signin when not signed in. - if !ctx.IsSigned { + if !options.SignOutRequire && !ctx.IsSigned && !auth.IsAPIPath(ctx.Req.URL.Path) { succeed, err := AutoSignIn(ctx) if err != nil { ctx.Handle(500, "AutoSignIn", err) return } else if succeed { - ctx.Redirect(ctx.Req.URL.Path) + ctx.Redirect(setting.AppSubUrl + ctx.Req.RequestURI) return } } -- cgit v1.2.3