Added message alerts when login failed due to github team membership or email domain requirement, #1731, #1660

This commit is contained in:
Torkel Ödegaard
2015-04-29 10:08:01 +02:00
parent 32fa8180fa
commit 0d3fbb8659
3 changed files with 14 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ package api
import (
"errors"
"fmt"
"net/url"
"golang.org/x/oauth2"
@@ -46,7 +47,7 @@ func OAuthLogin(ctx *middleware.Context) {
userInfo, err := connect.UserInfo(token)
if err != nil {
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 {
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
if !connect.IsEmailAllowed(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
}