Skip to content

Commit

Permalink
Merge pull request #22 from clementauger/fix#19
Browse files Browse the repository at this point in the history
Fix #19 automatically generate an user handle if it is empty
  • Loading branch information
knadh authored Aug 25, 2020
2 parents ff33147 + 5c21d5d commit 979fe77
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ func handleLogin(w http.ResponseWriter, r *http.Request) {
return
}

if req.Handle == "" {
h, err := hub.GenerateGUID(8)
if err != nil {
app.logger.Printf("error generating uniq handle: %v", err)
respondJSON(w, nil, errors.New("error generating uniq handle"), http.StatusInternalServerError)
return
}
req.Handle = h
}

// Validate password.
if err := bcrypt.CompareHashAndPassword(room.Password, []byte(req.Password)); err != nil {
respondJSON(w, nil, errors.New("incorrect password"), http.StatusForbidden)
Expand Down

0 comments on commit 979fe77

Please sign in to comment.