added length check for api name

main
alex 2023-10-14 20:51:13 +02:00
parent 9a8530dbfd
commit ea36bcf963
3 changed files with 13 additions and 0 deletions

7
commit_and_push.sh Executable file
View File

@ -0,0 +1,7 @@
git add *
read -p "Commit message: " commit_message
git commit -m "$commit_message"
git push -u origin main

View File

@ -17,6 +17,8 @@ const (
MaxEquipmentDocumentationTitleLength = "60"
MaxEquipmentDocumentationNoteLength = 2000
MaxNoficationTitleLength = "255"
MinUserApiKeyNameLength = 2
MaxUserApiKeyNameLength = 30
LenHeaderXAuthorization = 36
lenHeaderXAuthorization = "36"

View File

@ -993,6 +993,10 @@ func GetUserApiKeys(userId string) []structs.UserApiKey {
}
func CreateNewUserApiKey(userId string, apiName string) {
if len(apiName) < utils.MinUserApiKeyNameLength || len(apiName) > utils.MaxUserApiKeyNameLength {
return
}
token, err := rsutils.GenerateSession()
if err != nil {