fix(userstore): check compatibility and try to fix issues
This commit is contained in:
parent
f16ffe3547
commit
f587c6cc36
1 changed files with 21 additions and 0 deletions
|
@ -58,6 +58,11 @@ func NewServer(cfg gocfg.ICfg) (*Server, error) {
|
|||
return nil, fmt.Errorf("init handlers error: %w", err)
|
||||
}
|
||||
|
||||
err = checkCompatibility(deps)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("fail to check compatibility: %w", err)
|
||||
}
|
||||
|
||||
port := cfg.GrabInt("Server.Port")
|
||||
portStr, ok := cfg.String("ENV.PORT")
|
||||
if ok && portStr != "" {
|
||||
|
@ -82,6 +87,22 @@ func NewServer(cfg gocfg.ICfg) (*Server, error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
func checkCompatibility(deps *depidx.Deps) error {
|
||||
users, err := deps.Users().ListUsers()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, user := range users {
|
||||
fmt.Println(user, user.Preferences)
|
||||
if user.Preferences == nil {
|
||||
deps.Users().SetPreferences(user.ID, &userstore.DefaultPreferences)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func mkRoot(rootPath string) {
|
||||
info, err := os.Stat(rootPath)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue