Service accounts: make is_service_account nullable (#45541)

* add base nullable migration to is_service_account

Co-authored-by: Jeremy Price <jeremy.price@grafana.com>

* fix postgres migration

* ServiceAccounts: ensure SA is set to false when creating a user

Co-authored-by: Jeremy Price <jeremy.price@grafana.com>
This commit is contained in:
J Guerreiro
2022-02-18 13:08:00 +01:00
committed by GitHub
co-authored by Jeremy Price
parent 0838f4b1ad
commit 0ec21a4ed6
3 changed files with 29 additions and 12 deletions
+14 -12
View File
@@ -113,17 +113,18 @@ func (ss *SQLStore) createUser(ctx context.Context, sess *DBSession, args userCr
// create user
user = models.User{
Email: args.Email,
Name: args.Name,
Login: args.Login,
Company: args.Company,
IsAdmin: args.IsAdmin,
IsDisabled: args.IsDisabled,
OrgId: orgID,
EmailVerified: args.EmailVerified,
Created: time.Now(),
Updated: time.Now(),
LastSeenAt: time.Now().AddDate(-10, 0, 0),
Email: args.Email,
Name: args.Name,
Login: args.Login,
Company: args.Company,
IsAdmin: args.IsAdmin,
IsDisabled: args.IsDisabled,
OrgId: orgID,
EmailVerified: args.EmailVerified,
Created: time.Now(),
Updated: time.Now(),
LastSeenAt: time.Now().AddDate(-10, 0, 0),
IsServiceAccount: false,
}
salt, err := util.GetRandomString(10)
@@ -630,7 +631,8 @@ func SearchUsers(ctx context.Context, query *models.SearchUsersQuery) error {
// TODO: add to chore, for cleaning up after we have created
// service accounts table in the modelling
whereConditions = append(whereConditions, "u.is_service_account = false")
whereConditions = append(whereConditions, "u.is_service_account = ?")
whereParams = append(whereParams, dialect.BooleanStr(false))
// Join with only most recent auth module
joinCondition := `(