forked from forgejo/forgejo
Fix recovery middleware to render gitea style page. (#13857)
* Some changes to fix recovery * Move Recovery to middlewares * Remove trace code * Fix lint * add session middleware and remove dependent on macaron for sso * Fix panic 500 page rendering * Fix bugs * Fix fmt * Fix vendor * recover unnecessary change * Fix lint and addd some comments about the copied codes. * Use util.StatDir instead of com.StatDir Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
126c9331d6
commit
15a475b7db
75 changed files with 5233 additions and 307 deletions
33
modules/auth/sso/user.go
Normal file
33
modules/auth/sso/user.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package sso
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
)
|
||||
|
||||
// SignedInUser returns the user object of signed user.
|
||||
// It returns a bool value to indicate whether user uses basic auth or not.
|
||||
func SignedInUser(req *http.Request, ds DataStore, sess SessionStore) (*models.User, bool) {
|
||||
if !models.HasEngine {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// Try to sign in with each of the enabled plugins
|
||||
for _, ssoMethod := range Methods() {
|
||||
if !ssoMethod.IsEnabled() {
|
||||
continue
|
||||
}
|
||||
user := ssoMethod.VerifyAuthData(req, ds, sess)
|
||||
if user != nil {
|
||||
_, isBasic := ssoMethod.(*Basic)
|
||||
return user, isBasic
|
||||
}
|
||||
}
|
||||
|
||||
return nil, false
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue