auth
auth/profile.go
Remove concept of usernames. We really have no reason to use usernames, and they're complicating things more than they need to. We're going to keep logins the same, because we want to be able to support OAuth2/OpenID/whatever logins in the future, and keeping a type associated with those logins is probably for the best.
1.1 --- a/profile.go Sat Apr 11 14:13:52 2015 -0400 1.2 +++ b/profile.go Sat Apr 11 14:39:51 2015 -0400 1.3 @@ -10,7 +10,6 @@ 1.4 "time" 1.5 1.6 "code.secondbit.org/uuid.hg" 1.7 - "github.com/extemporalgenome/slug" 1.8 "github.com/gorilla/mux" 1.9 ) 1.10 1.11 @@ -23,8 +22,6 @@ 1.12 CurPassphraseScheme = 1 1.13 // MaxNameLength is the maximum length, in bytes, of a name, exclusive. 1.14 MaxNameLength = 64 1.15 - // MaxUsernameLength is the maximum length, in bytes, of a username, exclusive. 1.16 - MaxUsernameLength = 16 1.17 // MaxEmailLength is the maximum length, in bytes, of an email address, exclusive. 1.18 MaxEmailLength = 64 1.19 ) 1.20 @@ -68,8 +65,7 @@ 1.21 ) 1.22 1.23 // Profile represents a single user of the service, 1.24 -// including their authentication information, but not 1.25 -// including their username or email. 1.26 +// including their authentication information. 1.27 type Profile struct { 1.28 ID uuid.ID `json:"id,omitempty"` 1.29 Name string `json:"name,omitempty"` 1.30 @@ -211,7 +207,6 @@ 1.31 } 1.32 1.33 type newProfileRequest struct { 1.34 - Username string `json:"username"` 1.35 Email string `json:"email"` 1.36 Passphrase string `json:"passphrase"` 1.37 Name string `json:"name"` 1.38 @@ -221,7 +216,6 @@ 1.39 errors := []requestError{} 1.40 req.Name = strings.TrimSpace(req.Name) 1.41 req.Email = strings.TrimSpace(req.Email) 1.42 - req.Username = slug.SlugAscii(strings.TrimSpace(req.Username)) 1.43 if len(req.Passphrase) < MinPassphraseLength { 1.44 errors = append(errors, requestError{ 1.45 Slug: requestErrInsufficient, 1.46 @@ -240,12 +234,6 @@ 1.47 Field: "/name", 1.48 }) 1.49 } 1.50 - if len(req.Username) > MaxUsernameLength { 1.51 - errors = append(errors, requestError{ 1.52 - Slug: requestErrOverflow, 1.53 - Field: "/username", 1.54 - }) 1.55 - } 1.56 if req.Email == "" { 1.57 errors = append(errors, requestError{ 1.58 Slug: requestErrMissing, 1.59 @@ -501,21 +489,6 @@ 1.60 return 1.61 } 1.62 logins = append(logins, login) 1.63 - if req.Username != "" { 1.64 - login.Type = "username" 1.65 - login.Value = req.Username 1.66 - err = context.AddLogin(login) 1.67 - if err != nil { 1.68 - if err == ErrLoginAlreadyExists { 1.69 - encode(w, r, http.StatusBadRequest, response{Errors: []requestError{{Slug: requestErrConflict, Field: "/username"}}}) 1.70 - return 1.71 - } 1.72 - log.Printf("Error adding login: %#+v\n", err) 1.73 - encode(w, r, http.StatusInternalServerError, actOfGodResponse) 1.74 - return 1.75 - } 1.76 - logins = append(logins, login) 1.77 - } 1.78 resp := response{ 1.79 Logins: logins, 1.80 Profiles: []Profile{profile},