Reserved username check on signup page

This commit is contained in:
Noah Petherbridge 2023-09-09 12:26:51 -07:00
parent 618acc9f92
commit 1e7ea6830c

View File

@ -5,6 +5,7 @@ import (
"net/http" "net/http"
"strings" "strings"
"code.nonshy.com/nonshy/website/pkg/config"
"code.nonshy.com/nonshy/website/pkg/models" "code.nonshy.com/nonshy/website/pkg/models"
) )
@ -49,6 +50,16 @@ func UsernameCheck() http.HandlerFunc {
return return
} }
// Is it reserved?
for _, cmp := range config.ReservedUsernames {
if username == cmp {
SendJSON(w, http.StatusOK, Response{
Error: "That username is reserved, please choose a different username.",
})
return
}
}
// Send success response. // Send success response.
SendJSON(w, http.StatusOK, Response{ SendJSON(w, http.StatusOK, Response{
OK: true, OK: true,