diff options
author | jan <jan@ruken.pw> | 2016-11-02 14:27:59 (UTC) |
---|---|---|
committer | jan <jan@ruken.pw> | 2016-11-02 14:27:59 (UTC) |
commit | 71e3b22bcc79168f0bed6e2f6b7d3e34a3b641d4 (patch) | |
tree | a060682ef9b6c7fbcf3afda2d642b429a6ac1863 | |
parent | fb42c216818e05af7fce1f41908bdb969ba43903 (diff) |
ich hasse lars
-rw-r--r-- | charakterin.go | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/charakterin.go b/charakterin.go index b1500f0..415c94b 100644 --- a/charakterin.go +++ b/charakterin.go | |||
@@ -38,6 +38,7 @@ type Charakterin struct { | |||
38 | } | 38 | } |
39 | 39 | ||
40 | var reEmail, _ = regexp.Compile(`(\w[-._\w]*\w@\w[-._\w]*\w\.\w{2,})`) | 40 | var reEmail, _ = regexp.Compile(`(\w[-._\w]*\w@\w[-._\w]*\w\.\w{2,})`) |
41 | var reUsername, _ = regexp.Compile(`^(\w+( \w+)?)+$`) | ||
41 | 42 | ||
42 | // New erstellt eine neue Instanz von Charakterin. | 43 | // New erstellt eine neue Instanz von Charakterin. |
43 | func New(db *sql.DB) *Charakterin { | 44 | func New(db *sql.DB) *Charakterin { |
@@ -229,6 +230,19 @@ func (c *Charakterin) SaveUserRoute(w http.ResponseWriter, r *http.Request) { | |||
229 | curPass := values.Get("current_password") | 230 | curPass := values.Get("current_password") |
230 | newPass := values.Get("new_password") | 231 | newPass := values.Get("new_password") |
231 | 232 | ||
233 | if len(displayName) < 3 || !reUsername.MatchString(displayName) { | ||
234 | data := make(map[string]interface{}) | ||
235 | data["error"] = "Ich ficke deinen Usernamen, Lars" | ||
236 | c.DisplayUserSettingsWithData(w, r, data) | ||
237 | return | ||
238 | } | ||
239 | if len(newPass) < 3 { | ||
240 | data := make(map[string]interface{}) | ||
241 | data["error"] = "Passwort zu kurz, du Hurensohn" | ||
242 | c.DisplayUserSettingsWithData(w, r, data) | ||
243 | return | ||
244 | } | ||
245 | |||
232 | if len(curPass) > 0 && len(newPass) > 0 { | 246 | if len(curPass) > 0 && len(newPass) > 0 { |
233 | var success bool | 247 | var success bool |
234 | err = c.Database.QueryRow("SELECT login.compare_passwords($1, $2)", user.Password, curPass).Scan(&success) | 248 | err = c.Database.QueryRow("SELECT login.compare_passwords($1, $2)", user.Password, curPass).Scan(&success) |
@@ -305,9 +319,9 @@ func (c *Charakterin) Register(w http.ResponseWriter, r *http.Request) { | |||
305 | password := values.Get("password") | 319 | password := values.Get("password") |
306 | email := values.Get("email") | 320 | email := values.Get("email") |
307 | 321 | ||
308 | if len(username) < 3 { | 322 | if len(username) < 3 || !reUsername.MatchString(username) { |
309 | data := make(map[string]interface{}) | 323 | data := make(map[string]interface{}) |
310 | data["error"] = "Username zu kurz, du Hurensohn" | 324 | data["error"] = "Ich ficke deinen Usernamen, Lars" |
311 | data["previous_email"] = email | 325 | data["previous_email"] = email |
312 | c.DisplayRegistrationWithData(w, r, data) | 326 | c.DisplayRegistrationWithData(w, r, data) |
313 | return | 327 | return |