Merge pull request #38 from george-e-shaw-iv/master

Check if user already exists in registration process
This commit is contained in:
George Shaw 2017-10-27 14:44:12 -05:00 committed by GitHub
commit 4a29c8a683
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -84,6 +84,12 @@ func UserRegistration(res http.ResponseWriter, req *http.Request) bool {
}
defer ds.Close()
err = ds.Get(database.BUCKET_USERS, []byte(userRequestData.User), &userDatabaseData)
if err != database.ErrKeyNotExist {
http.Error(res, "Username already exists in the database", http.StatusBadRequest)
return false
}
userDatabaseData.Pass, err = encryption.HashPassword(userRequestData.Pass)
if err != nil {
http.Error(res, err.Error(), http.StatusBadRequest)