fix: primary domain claim (#1082)

* fix: primary domain scope (overwrite by roles and rogue `:`)

* disable wrong users

* fix test

* show requested org name

* only show domain when selected
This commit is contained in:
Livio Amstutz
2020-12-14 10:54:29 +01:00
committed by GitHub
parent c6fed8ae86
commit b71a444e86
27 changed files with 245 additions and 148 deletions
+10 -11
View File
@@ -267,6 +267,7 @@ func (l *Login) getBaseData(r *http.Request, authReq *model.AuthRequest, title s
Theme: l.getTheme(r),
ThemeMode: l.getThemeMode(r),
OrgID: l.getOrgID(authReq),
OrgName: l.getOrgName(authReq),
AuthReqID: getRequestID(authReq, r),
CSRF: csrf.TemplateField(r),
Nonce: http_mw.GetNonce(r),
@@ -312,20 +313,17 @@ func (l *Login) getOrgID(authReq *model.AuthRequest) string {
if authReq == nil {
return ""
}
if authReq.UserOrgID != "" {
return authReq.UserOrgID
if authReq.RequestedOrgID != "" {
return authReq.RequestedOrgID
}
if authReq.Request == nil {
return authReq.UserOrgID
}
func (l *Login) getOrgName(authReq *model.AuthRequest) string {
if authReq == nil {
return ""
}
primaryDomain := authReq.GetScopeOrgPrimaryDomain()
if primaryDomain != "" {
org, _ := l.authRepo.GetOrgByPrimaryDomain(primaryDomain)
if org != nil {
return org.ID
}
}
return ""
return authReq.RequestedOrgName
}
func getRequestID(authReq *model.AuthRequest, r *http.Request) string {
@@ -355,6 +353,7 @@ type baseData struct {
Theme string
ThemeMode string
OrgID string
OrgName string
AuthReqID string
CSRF template.HTML
Nonce string