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