user repo now adds a default scope on create and scopes can be replaced for a user
This commit is contained in:
parent
f67ed03c9d
commit
f159582d34
@ -22,7 +22,7 @@ type IUserTable interface {
|
|||||||
Update(id int, entity domain.UserEntity) error
|
Update(id int, entity domain.UserEntity) error
|
||||||
UpdatePassword(name, password string) error
|
UpdatePassword(name, password string) error
|
||||||
CheckUserHash(name, password string) error
|
CheckUserHash(name, password string) error
|
||||||
AddScope(name, scope string) error
|
UpdateScopes(name, scope string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a new instance of UserRepository with the bound sql
|
// Creates a new instance of UserRepository with the bound sql
|
||||||
@ -66,8 +66,8 @@ func (ur UserRepository) Create(name, password, scope string) (int64, error) {
|
|||||||
dt := time.Now()
|
dt := time.Now()
|
||||||
queryBuilder := sqlbuilder.NewInsertBuilder()
|
queryBuilder := sqlbuilder.NewInsertBuilder()
|
||||||
queryBuilder.InsertInto("users")
|
queryBuilder.InsertInto("users")
|
||||||
queryBuilder.Cols("Name", "Hash", "LastUpdated", "CreatedAt")
|
queryBuilder.Cols("Name", "Hash", "LastUpdated", "CreatedAt", "Scopes")
|
||||||
queryBuilder.Values(name, string(hash), dt, dt)
|
queryBuilder.Values(name, string(hash), dt, dt, scope)
|
||||||
query, args := queryBuilder.Build()
|
query, args := queryBuilder.Build()
|
||||||
|
|
||||||
_, err = ur.connection.Exec(query, args...)
|
_, err = ur.connection.Exec(query, args...)
|
||||||
@ -110,7 +110,7 @@ func (ur UserRepository) CheckUserHash(name, password string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ur UserRepository) AddScope(name, scope string) error {
|
func (ur UserRepository) UpdateScopes(name, scope string) error {
|
||||||
builder := sqlbuilder.NewUpdateBuilder()
|
builder := sqlbuilder.NewUpdateBuilder()
|
||||||
builder.Update("users")
|
builder.Update("users")
|
||||||
builder.Set (
|
builder.Set (
|
||||||
|
Loading…
Reference in New Issue
Block a user