forked from railwayapp/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.go
More file actions
32 lines (25 loc) · 644 Bytes
/
Copy pathuser.go
File metadata and controls
32 lines (25 loc) · 644 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package configs
import (
"github.com/railwayapp/cli/entity"
"github.com/railwayapp/cli/errors"
)
func (c *Configs) GetUserConfigs() (*entity.UserConfig, error) {
var rootCfg *entity.RootConfig
rootCfg, err := c.GetRootConfigs()
if err != nil {
return nil, errors.UserConfigNotFound
}
if rootCfg.User.Token == "" {
return nil, errors.UserConfigNotFound
}
return &rootCfg.User, nil
}
func (c *Configs) SetUserConfigs(cfg *entity.UserConfig) error {
var rootCfg *entity.RootConfig
rootCfg, err := c.GetRootConfigs()
if err != nil {
rootCfg = &entity.RootConfig{}
}
rootCfg.User = *cfg
return c.SetRootConfig(rootCfg)
}