work on #1891
This commit is contained in:
parent
915bf1d2e3
commit
9330c943cd
4 changed files with 16 additions and 11 deletions
File diff suppressed because one or more lines are too long
|
@ -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 options.AdminRequire {
|
||||||
if !ctx.User.IsAdmin {
|
if !ctx.User.IsAdmin {
|
||||||
ctx.Error(403)
|
ctx.Error(403)
|
||||||
|
|
|
@ -209,14 +209,6 @@ func Contexter() macaron.Handler {
|
||||||
|
|
||||||
ctx.Data["PageStartTime"] = time.Now()
|
ctx.Data["PageStartTime"] = time.Now()
|
||||||
|
|
||||||
// Check auto-signin.
|
|
||||||
if sess.Get("uid") == nil {
|
|
||||||
if _, err := AutoSignIn(ctx); err != nil {
|
|
||||||
ctx.Handle(500, "AutoSignIn", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get user from session if logined.
|
// Get user from session if logined.
|
||||||
ctx.User, ctx.IsBasicAuth = auth.SignedInUser(ctx.Context, ctx.Session)
|
ctx.User, ctx.IsBasicAuth = auth.SignedInUser(ctx.Context, ctx.Session)
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,9 @@ func SignIn(ctx *middleware.Context) {
|
||||||
if redirectTo, _ := url.QueryUnescape(ctx.GetCookie("redirect_to")); len(redirectTo) > 0 {
|
if redirectTo, _ := url.QueryUnescape(ctx.GetCookie("redirect_to")); len(redirectTo) > 0 {
|
||||||
ctx.SetCookie("redirect_to", "", -1, setting.AppSubUrl)
|
ctx.SetCookie("redirect_to", "", -1, setting.AppSubUrl)
|
||||||
ctx.Redirect(redirectTo)
|
ctx.Redirect(redirectTo)
|
||||||
}
|
} else {
|
||||||
ctx.Redirect(setting.AppSubUrl + "/")
|
ctx.Redirect(setting.AppSubUrl + "/")
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue