diff --git a/conf/wide.go b/conf/wide.go index a789795..b1e7780 100644 --- a/conf/wide.go +++ b/conf/wide.go @@ -57,6 +57,7 @@ type LatestSessionContent struct { type User struct { Name string Password string + Email string Workspace string // the GOPATH of this user Locale string GoFormat string @@ -67,9 +68,9 @@ type User struct { LatestSessionContent *LatestSessionContent } -// NewUser creates a user with the specified username, password and workspace. -func NewUser(username, password, workspace string) *User { - return &User{Name: username, Password: password, Workspace: workspace, +// NewUser creates a user with the specified username, password, email and workspace. +func NewUser(username, password, email, workspace string) *User { + return &User{Name: username, Password: password, Email: email, 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"}} diff --git a/conf/wide.json b/conf/wide.json index 25c4b49..71c259e 100644 --- a/conf/wide.json +++ b/conf/wide.json @@ -17,6 +17,7 @@ { "Name": "admin", "Password": "admin", + "Email": "", "Workspace": "${GOPATH}", "Locale": "en_US", "GoFormat": "gofmt", diff --git a/i18n/en_US.json b/i18n/en_US.json index 339aaa0..2a69661 100644 --- a/i18n/en_US.json +++ b/i18n/en_US.json @@ -118,6 +118,7 @@ "team": "Team", "sing_up_error": "Sign Up Error", "user_name_ruler": "Username only by az, AZ, 0-9, _ consisting of a length of 16", + "invalid_email": "Invalid Email", "password_no_match": "Password doesn't match the confirmation", "discard": "Discard", "close": "Close", @@ -154,5 +155,6 @@ "select_identifier": "Select Identifier", "source": "Source", "toggle_comment": "Toggle Comment", - "find_in_files": "Find in Files" + "find_in_files": "Find in Files", + "email": "Email" } \ No newline at end of file diff --git a/i18n/ja_JP.json b/i18n/ja_JP.json index e2e0db0..d3c11d8 100644 --- a/i18n/ja_JP.json +++ b/i18n/ja_JP.json @@ -118,6 +118,7 @@ "team": "チーム", "sing_up_error": "登録に失敗しました", "user_name_ruler": "16の長さからなる_ AZ、AZ、0-9、によってユーザ名のみ", + "invalid_email": "無効な電子メール", "password_no_match": "一貫性のないパスワード入力", "discard": "あきらめる", "close": "クローズ", @@ -154,5 +155,6 @@ "select_identifier": "選択識別子", "source": "ソース", "toggle_comment": "トグルコメント", - "find_in_files": "ファイルから検索" + "find_in_files": "ファイルから検索", + "email": "Eメール" } diff --git a/i18n/zh_CN.json b/i18n/zh_CN.json index 394fd2f..072947c 100644 --- a/i18n/zh_CN.json +++ b/i18n/zh_CN.json @@ -118,6 +118,7 @@ "team": "团队", "sing_up_error": "注册失败", "user_name_ruler": "用户名只能由 a-z, A-Z, 0-9, _ 组成,长度为16", + "invalid_email": "无效的电子邮件", "password_no_match": "密码输入不一致", "discard": "放弃", "close": "关闭", @@ -154,5 +155,6 @@ "select_identifier": "选择标识符", "source": "源码", "toggle_comment": "注释", - "find_in_files": "在文件中查找" + "find_in_files": "在文件中查找", + "email": "电子邮件" } \ No newline at end of file diff --git a/i18n/zh_TW.json b/i18n/zh_TW.json index 22bbbdc..31a7d70 100644 --- a/i18n/zh_TW.json +++ b/i18n/zh_TW.json @@ -118,6 +118,7 @@ "team": "團隊", "sing_up_error": "註冊失敗", "user_name_ruler": "用戶名只能由az, AZ, 0-9, _ 組成,長度為16", + "invalid_email": "無效的電子郵件", "password_no_match": "密碼輸入不一致", "discard": "放棄", "close": "關閉", @@ -154,5 +155,6 @@ "select_identifier": "選擇標識符", "source": "源代碼", "toggle_comment": "註釋", - "find_in_files": "在文件中查找" + "find_in_files": "在文件中查找", + "email": "電子郵件" } \ No newline at end of file diff --git a/session/users.go b/session/users.go index a6b3dad..d2fd5a6 100644 --- a/session/users.go +++ b/session/users.go @@ -32,7 +32,10 @@ import ( ) const ( + // TODO: i18n + userExists = "user exists" + emailExists = "email exists" userCreated = "user created" userCreateError = "user create error" ) @@ -89,6 +92,7 @@ func PreferenceHandler(w http.ResponseWriter, r *http.Request) { Workspace string Username string Password string + Email string Locale string Theme string EditorFontFamily string @@ -110,6 +114,7 @@ func PreferenceHandler(w http.ResponseWriter, r *http.Request) { user.GoFormat = args.GoFmt user.Workspace = args.Workspace user.Password = args.Password + user.Email = args.Email user.Locale = args.Locale user.Theme = args.Theme user.Editor.FontFamily = args.EditorFontFamily @@ -240,21 +245,22 @@ func SignUpUser(w http.ResponseWriter, r *http.Request) { username := args["username"].(string) password := args["password"].(string) + email := args["email"].(string) - msg := addUser(username, password) + msg := addUser(username, password, email) if userCreated != msg { succ = false data["msg"] = msg } } -// addUser add a user with the specified username and password. +// addUser add a user with the specified username, password and email. // // 1. create the user's workspace // 2. generate 'Hello, 世界' demo code in the workspace // 3. update the user customized configurations, such as style.css // 4. serve files of the user's workspace via HTTP -func addUser(username, password string) string { +func addUser(username, password, email string) string { addUserMutex.Lock() defer addUserMutex.Unlock() @@ -262,13 +268,17 @@ func addUser(username, password string) string { if user.Name == username { return userExists } + + if user.Email == email { + return emailExists + } } firstUserWorkspace := conf.Wide.GetUserWorkspace(conf.Wide.Users[0].Name) dir := filepath.Dir(firstUserWorkspace) workspace := filepath.Join(dir, username) - newUser := conf.NewUser(username, password, workspace) + newUser := conf.NewUser(username, password, email, workspace) conf.Wide.Users = append(conf.Wide.Users, newUser) if !conf.Save() { diff --git a/static/css/sign.css b/static/css/sign.css index fb8eee8..35a9d9b 100644 --- a/static/css/sign.css +++ b/static/css/sign.css @@ -155,7 +155,7 @@ } .form.sign-up { - margin-top: -71px; + margin-top: -108px; } #signUpBtn { diff --git a/static/js/menu.js b/static/js/menu.js index dc90b9b..b2df2d7 100644 --- a/static/js/menu.js +++ b/static/js/menu.js @@ -364,6 +364,7 @@ var menu = { $goFmt = $dialogPreference.find("input[name=goFmt]"), $workspace = $dialogPreference.find("input[name=workspace]"), $password = $dialogPreference.find("input[name=password]"), + $email = $dialogPreference.find("input[name=email]"), $locale = $dialogPreference.find("input[name=locale]"), $theme = $dialogPreference.find("input[name=theme]"), $editorFontFamily = $dialogPreference.find("input[name=editorFontFamily]"), @@ -378,6 +379,7 @@ var menu = { "goFmt": $goFmt.val(), "workspace": $workspace.val(), "password": $password.val(), + "email": $email.val(), "locale": $locale.val(), "theme": $theme.val(), "editorFontFamily": $editorFontFamily.val(), @@ -401,6 +403,7 @@ var menu = { $goFmt.data("value", $goFmt.val()); $workspace.data("value", $workspace.val()); $password.data("value", $password.val()); + $email.data("value", $email.val()); $locale.data("value", $locale.val()); $theme.data("value", $theme.val()); $editorFontFamily.data("value", $editorFontFamily.val()); diff --git a/views/preference.html b/views/preference.html index 94eee8b..29c5127 100644 --- a/views/preference.html +++ b/views/preference.html @@ -88,6 +88,10 @@
+