wip
This commit is contained in:
parent
48e8d96726
commit
cf7d098a5f
@ -94,3 +94,16 @@ func (u *Urbac) newPrivilege(ctx context.Context, code, label string, parent str
|
|||||||
|
|
||||||
return p, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *Urbac) newUser(target *model.User) (*model.User, error) {
|
||||||
|
result := u.store.Session().Create(target)
|
||||||
|
if result.Error != nil {
|
||||||
|
return nil, result.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
if result.RowsAffected != 1 {
|
||||||
|
return nil, fmt.Errorf("invalid rows affected")
|
||||||
|
}
|
||||||
|
|
||||||
|
return target, nil
|
||||||
|
}
|
||||||
|
@ -66,10 +66,10 @@ func New(opts ...Option) (*Urbac, error) {
|
|||||||
Password: tool.NewPassword("123456"),
|
Password: tool.NewPassword("123456"),
|
||||||
Status: model.StatusActive,
|
Status: model.StatusActive,
|
||||||
Nickname: "管理员",
|
Nickname: "管理员",
|
||||||
RoleNames: []string{"admin"},
|
RoleNames: []string{rootRole.Code},
|
||||||
}
|
}
|
||||||
|
|
||||||
u.newUser()
|
_, err = u.newUser(rootUser)
|
||||||
|
|
||||||
return u, nil
|
return u, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user