|
|
|
@ -4,6 +4,7 @@ import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"fmt"
|
|
|
|
|
"net/http"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/labstack/echo/v4"
|
|
|
|
@ -140,7 +141,7 @@ func (s *APIV1Service) CreateUser(c echo.Context) error {
|
|
|
|
|
if err := userCreate.Validate(); err != nil {
|
|
|
|
|
return echo.NewHTTPError(http.StatusBadRequest, "Invalid user create format").SetInternal(err)
|
|
|
|
|
}
|
|
|
|
|
if !usernameMatcher.MatchString(userCreate.Username) {
|
|
|
|
|
if !usernameMatcher.MatchString(strings.ToLower(userCreate.Username)) {
|
|
|
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid username %s", userCreate.Username)).SetInternal(err)
|
|
|
|
|
}
|
|
|
|
|
// Disallow host user to be created.
|
|
|
|
@ -365,7 +366,7 @@ func (s *APIV1Service) UpdateUser(c echo.Context) error {
|
|
|
|
|
userUpdate.RowStatus = &rowStatus
|
|
|
|
|
}
|
|
|
|
|
if request.Username != nil {
|
|
|
|
|
if !usernameMatcher.MatchString(*request.Username) {
|
|
|
|
|
if !usernameMatcher.MatchString(strings.ToLower(*request.Username)) {
|
|
|
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid username %s", *request.Username)).SetInternal(err)
|
|
|
|
|
}
|
|
|
|
|
userUpdate.Username = request.Username
|
|
|
|
|