|
@@ -3,6 +3,7 @@ package api
|
|
|
import (
|
|
import (
|
|
|
"errors"
|
|
"errors"
|
|
|
"fmt"
|
|
"fmt"
|
|
|
|
|
+ "net/url"
|
|
|
|
|
|
|
|
"golang.org/x/oauth2"
|
|
"golang.org/x/oauth2"
|
|
|
|
|
|
|
@@ -46,7 +47,7 @@ func OAuthLogin(ctx *middleware.Context) {
|
|
|
userInfo, err := connect.UserInfo(token)
|
|
userInfo, err := connect.UserInfo(token)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
if err == social.ErrMissingTeamMembership {
|
|
if err == social.ErrMissingTeamMembership {
|
|
|
- ctx.Redirect(setting.AppSubUrl + "/login?missing_team_membership=1")
|
|
|
|
|
|
|
+ ctx.Redirect(setting.AppSubUrl + "/login?failedMsg=" + url.QueryEscape("Required Github team membership not fulfilled"))
|
|
|
} else {
|
|
} else {
|
|
|
ctx.Handle(500, fmt.Sprintf("login.OAuthLogin(get info from %s)", name), err)
|
|
ctx.Handle(500, fmt.Sprintf("login.OAuthLogin(get info from %s)", name), err)
|
|
|
}
|
|
}
|
|
@@ -58,7 +59,7 @@ func OAuthLogin(ctx *middleware.Context) {
|
|
|
// validate that the email is allowed to login to grafana
|
|
// validate that the email is allowed to login to grafana
|
|
|
if !connect.IsEmailAllowed(userInfo.Email) {
|
|
if !connect.IsEmailAllowed(userInfo.Email) {
|
|
|
log.Info("OAuth login attempt with unallowed email, %s", userInfo.Email)
|
|
log.Info("OAuth login attempt with unallowed email, %s", userInfo.Email)
|
|
|
- ctx.Redirect(setting.AppSubUrl + "/login?email_not_allowed=1")
|
|
|
|
|
|
|
+ ctx.Redirect(setting.AppSubUrl + "/login?failedMsg=" + url.QueryEscape("Required email domain not fulfilled"))
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|