refactor new user ♻️
This commit is contained in:
parent
8b2ccb3214
commit
34845de308
|
@ -62,6 +62,15 @@ type User struct {
|
|||
LatestSessionContent *LatestSessionContent
|
||||
}
|
||||
|
||||
// NewUser creates a user with the specified username, password, workspace.
|
||||
func NewUser(username, password, workspace string) *User {
|
||||
return &User{Name: username, Password: password, Workspace: workspace,
|
||||
Locale: Wide.Locale, GoFormat: "gofmt", FontFamily: "Helvetica", FontSize: "13px",
|
||||
Theme: "default",
|
||||
Editor: &Editor{FontFamily: "Consolas, 'Courier New', monospace", FontSize: "inherit", Theme: "wide",
|
||||
TabSize: "4"}}
|
||||
}
|
||||
|
||||
// Editor configuration of a user.
|
||||
type Editor struct {
|
||||
FontFamily string
|
||||
|
|
|
@ -268,9 +268,7 @@ func addUser(username, password string) string {
|
|||
dir := filepath.Dir(firstUserWorkspace)
|
||||
workspace := filepath.Join(dir, username)
|
||||
|
||||
newUser := &conf.User{Name: username, Password: password, Workspace: workspace,
|
||||
Locale: conf.Wide.Locale, GoFormat: "gofmt", FontFamily: "Helvetica", FontSize: "13px",
|
||||
Editor: &conf.Editor{FontFamily: "Consolas, 'Courier New', monospace", FontSize: "inherit"}}
|
||||
newUser := conf.NewUser(username, password, workspace)
|
||||
conf.Wide.Users = append(conf.Wide.Users, newUser)
|
||||
|
||||
if !conf.Save() {
|
||||
|
|
Loading…
Reference in New Issue