* Auth: Fix SAML user IsExternallySynced not being set correctly (#98487)
(cherry picked from commit 345757c3ae)
* Test fixes
* lint
---------
Co-authored-by: xavi <114113189+volcanonoodle@users.noreply.github.com>
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/mail"
|
||||
|
||||
"github.com/grafana/grafana/pkg/middleware/cookies"
|
||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||
"github.com/grafana/grafana/pkg/services/login"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
)
|
||||
|
||||
func (hs *HTTPServer) GetRedirectURL(c *contextmodel.ReqContext) string {
|
||||
@@ -20,6 +24,20 @@ func (hs *HTTPServer) GetRedirectURL(c *contextmodel.ReqContext) string {
|
||||
return redirectURL
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) isExternalUser(ctx context.Context, userID int64) (bool, error) {
|
||||
getAuthQuery := login.GetAuthInfoQuery{UserId: userID}
|
||||
var err error
|
||||
if _, err = hs.authInfoService.GetAuthInfo(ctx, &getAuthQuery); err == nil {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
if errors.Is(err, user.ErrUserNotFound) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
return false, err
|
||||
}
|
||||
|
||||
func ValidateAndNormalizeEmail(email string) (string, error) {
|
||||
if email == "" {
|
||||
return "", nil
|
||||
|
||||
Reference in New Issue
Block a user