|
|
|
@@ -9,6 +9,9 @@ import ( |
|
|
|
"reflect" |
|
|
|
"strings" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/base" |
|
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/models" |
|
|
|
"code.gitea.io/gitea/modules/auth/sso" |
|
|
|
"code.gitea.io/gitea/modules/validation" |
|
|
|
@@ -31,6 +34,8 @@ func SignedInUser(ctx *macaron.Context, sess session.Store) (*models.User, bool) |
|
|
|
return nil, false |
|
|
|
} |
|
|
|
|
|
|
|
checkAutoLogin(ctx, sess) |
|
|
|
|
|
|
|
// Try to sign in with each of the enabled plugins |
|
|
|
for _, ssoMethod := range sso.Methods() { |
|
|
|
if !ssoMethod.IsEnabled() { |
|
|
|
@@ -46,6 +51,23 @@ func SignedInUser(ctx *macaron.Context, sess session.Store) (*models.User, bool) |
|
|
|
return nil, false |
|
|
|
} |
|
|
|
|
|
|
|
func checkAutoLogin(ctx *macaron.Context, sess session.Store) { |
|
|
|
uid := sess.Get("uid") |
|
|
|
if uid == nil { |
|
|
|
uname := ctx.GetCookie(setting.CookieUserName) |
|
|
|
|
|
|
|
u, err := models.GetUserByName(uname) |
|
|
|
if err == nil { |
|
|
|
|
|
|
|
if val, ok := ctx.GetSuperSecureCookie( |
|
|
|
base.EncodeMD5(u.Rands+u.Passwd), setting.CookieRememberName); ok && val == u.Name { |
|
|
|
sess.Set("uid", u.ID) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Form form binding interface |
|
|
|
type Form interface { |
|
|
|
binding.Validator |
|
|
|
|