Commit 8e0f091f by Oleg Gaidarenko Committed by GitHub

SQLStore: allow to look for `is_disabled` flag (#18032)

* Add support for `is_disabled` to `CreateUser()`

* Add support for `is_disabled` to `SearchUsers()`
  Had to add it as a `string` type not as `bool`, since if that's property
  is omitted, we would have add it to SQL request, which might be dangerous

* Restructure desctructive tests and add more
parent 09eb9a45
...@@ -62,6 +62,7 @@ type CreateUserCommand struct { ...@@ -62,6 +62,7 @@ type CreateUserCommand struct {
Password string Password string
EmailVerified bool EmailVerified bool
IsAdmin bool IsAdmin bool
IsDisabled bool
SkipOrgSetup bool SkipOrgSetup bool
DefaultOrgRole string DefaultOrgRole string
...@@ -146,6 +147,10 @@ type SearchUsersQuery struct { ...@@ -146,6 +147,10 @@ type SearchUsersQuery struct {
Limit int Limit int
AuthModule string AuthModule string
// We have to use string not bool, since there is cases when
// we don't care if user is disabled or not
IsDisabled string
Result SearchUserQueryResult Result SearchUserQueryResult
} }
......
...@@ -106,6 +106,7 @@ func CreateUser(ctx context.Context, cmd *models.CreateUserCommand) error { ...@@ -106,6 +106,7 @@ func CreateUser(ctx context.Context, cmd *models.CreateUserCommand) error {
Login: cmd.Login, Login: cmd.Login,
Company: cmd.Company, Company: cmd.Company,
IsAdmin: cmd.IsAdmin, IsAdmin: cmd.IsAdmin,
IsDisabled: cmd.IsDisabled,
OrgId: orgId, OrgId: orgId,
EmailVerified: cmd.EmailVerified, EmailVerified: cmd.EmailVerified,
Created: time.Now(), Created: time.Now(),
...@@ -455,6 +456,16 @@ func SearchUsers(query *models.SearchUsersQuery) error { ...@@ -455,6 +456,16 @@ func SearchUsers(query *models.SearchUsersQuery) error {
whereParams = append(whereParams, queryWithWildcards, queryWithWildcards, queryWithWildcards) whereParams = append(whereParams, queryWithWildcards, queryWithWildcards, queryWithWildcards)
} }
if query.IsDisabled != "" {
param, err := strconv.ParseBool(query.IsDisabled)
if err != nil {
return err
}
whereConditions = append(whereConditions, "is_disabled = ?")
whereParams = append(whereParams, param)
}
if query.AuthModule != "" { if query.AuthModule != "" {
whereConditions = append( whereConditions = append(
whereConditions, whereConditions,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment