Move SignedInUser to user service and RoleType and Roles to org (#53445)

* Move SignedInUser to user service and RoleType and Roles to org

* Use go naming convention for roles

* Fix some imports and leftovers

* Fix ldap debug test

* Fix lint

* Fix lint 2

* Fix lint 3

* Fix type and not needed conversion

* Clean up messages in api tests

* Clean up api tests 2
This commit is contained in:
idafurjes
2022-08-10 11:56:48 +02:00
committed by GitHub
parent 46004037e2
commit 6afad51761
278 changed files with 1758 additions and 1543 deletions
+10 -9
View File
@@ -7,6 +7,7 @@ import (
"github.com/grafana/grafana/pkg/events"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/org"
"xorm.io/xorm"
)
@@ -103,7 +104,7 @@ func isOrgNameTaken(name string, existingId int64, sess *DBSession) (bool, error
}
func (ss *SQLStore) createOrg(ctx context.Context, name string, userID int64, engine *xorm.Engine) (models.Org, error) {
org := models.Org{
orga := models.Org{
Name: name,
Created: time.Now(),
Updated: time.Now(),
@@ -115,14 +116,14 @@ func (ss *SQLStore) createOrg(ctx context.Context, name string, userID int64, en
return models.ErrOrgNameTaken
}
if _, err := sess.Insert(&org); err != nil {
if _, err := sess.Insert(&orga); err != nil {
return err
}
user := models.OrgUser{
OrgId: org.Id,
OrgId: orga.Id,
UserId: userID,
Role: models.ROLE_ADMIN,
Role: org.RoleAdmin,
Created: time.Now(),
Updated: time.Now(),
}
@@ -130,17 +131,17 @@ func (ss *SQLStore) createOrg(ctx context.Context, name string, userID int64, en
_, err := sess.Insert(&user)
sess.publishAfterCommit(&events.OrgCreated{
Timestamp: org.Created,
Id: org.Id,
Name: org.Name,
Timestamp: orga.Created,
Id: orga.Id,
Name: orga.Name,
})
return err
}, 0); err != nil {
return org, err
return orga, err
}
return org, nil
return orga, nil
}
// CreateOrgWithMember creates an organization with a certain name and a certain user as member.