mirror of
				https://github.com/grafana/grafana.git
				synced 2025-02-25 18:55:37 -06:00 
			
		
		
		
	Merge branch 'master' into gnet-oauth
Conflicts: pkg/api/login_oauth.go
This commit is contained in:
		@@ -3,7 +3,6 @@ package api
 | 
			
		||||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/url"
 | 
			
		||||
 | 
			
		||||
	"golang.org/x/oauth2"
 | 
			
		||||
 | 
			
		||||
@@ -46,9 +45,9 @@ func OAuthLogin(ctx *middleware.Context) {
 | 
			
		||||
	userInfo, err := connect.UserInfo(token)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		if err == social.ErrMissingTeamMembership {
 | 
			
		||||
			ctx.Redirect(setting.AppSubUrl + "/login?failedMsg=" + url.QueryEscape("Required team membership not fulfilled"))
 | 
			
		||||
			ctx.Redirect(setting.AppSubUrl + "/login?failCode=1000")
 | 
			
		||||
		} else if err == social.ErrMissingOrganizationMembership {
 | 
			
		||||
			ctx.Redirect(setting.AppSubUrl + "/login?failedMsg=" + url.QueryEscape("Required organization membership not fulfilled"))
 | 
			
		||||
			ctx.Redirect(setting.AppSubUrl + "/login?failCode=1001")
 | 
			
		||||
		} else {
 | 
			
		||||
			ctx.Handle(500, fmt.Sprintf("login.OAuthLogin(get info from %s)", name), err)
 | 
			
		||||
		}
 | 
			
		||||
@@ -60,7 +59,7 @@ func OAuthLogin(ctx *middleware.Context) {
 | 
			
		||||
	// validate that the email is allowed to login to grafana
 | 
			
		||||
	if !connect.IsEmailAllowed(userInfo.Email) {
 | 
			
		||||
		ctx.Logger.Info("OAuth login attempt with unallowed email", "email", userInfo.Email)
 | 
			
		||||
		ctx.Redirect(setting.AppSubUrl + "/login?failedMsg=" + url.QueryEscape("Required email domain not fulfilled"))
 | 
			
		||||
		ctx.Redirect(setting.AppSubUrl + "/login?failCode=1002")
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -141,8 +141,6 @@ func createRequest(repoUrl string, subPaths ...string) ([]byte, error) {
 | 
			
		||||
 | 
			
		||||
	req, err := http.NewRequest(http.MethodGet, u.String(), nil)
 | 
			
		||||
 | 
			
		||||
	logger.Info("grafanaVersion ", grafanaVersion)
 | 
			
		||||
 | 
			
		||||
	req.Header.Set("grafana-version", grafanaVersion)
 | 
			
		||||
	req.Header.Set("User-Agent", "grafana "+grafanaVersion)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user