refactor new user ♻️

This commit is contained in:
Liang Ding 2014-12-05 13:44:59 +08:00
parent 8b2ccb3214
commit 34845de308
2 changed files with 10 additions and 3 deletions

View File

@ -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

View File

@ -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() {