mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-02-15 16:55:05 +00:00
fix: remove custom claim key restrictions
This commit is contained in:
@@ -6,6 +6,6 @@ type CustomClaimDto struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CustomClaimCreateDto struct {
|
type CustomClaimCreateDto struct {
|
||||||
Key string `json:"key" binding:"required,claimKey"`
|
Key string `json:"key" binding:"required"`
|
||||||
Value string `json:"value" binding:"required"`
|
Value string `json:"value" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,22 +16,10 @@ var validateUsername validator.Func = func(fl validator.FieldLevel) bool {
|
|||||||
return matched
|
return matched
|
||||||
}
|
}
|
||||||
|
|
||||||
var validateClaimKey validator.Func = func(fl validator.FieldLevel) bool {
|
|
||||||
// The string can only contain letters and numbers
|
|
||||||
regex := "^[A-Za-z0-9]*$"
|
|
||||||
matched, _ := regexp.MatchString(regex, fl.Field().String())
|
|
||||||
return matched
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
|
if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
|
||||||
if err := v.RegisterValidation("username", validateUsername); err != nil {
|
if err := v.RegisterValidation("username", validateUsername); err != nil {
|
||||||
log.Fatalf("Failed to register custom validation: %v", err)
|
log.Fatalf("Failed to register custom validation: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
|
|
||||||
if err := v.RegisterValidation("claimKey", validateClaimKey); err != nil {
|
|
||||||
log.Fatalf("Failed to register custom validation: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
let filteredSuggestions: string[] = $state(suggestions.slice(0, suggestionLimit));
|
let filteredSuggestions: string[] = $state(suggestions.slice(0, suggestionLimit));
|
||||||
let selectedIndex = $state(-1);
|
let selectedIndex = $state(-1);
|
||||||
let keyError: string | undefined = $state();
|
|
||||||
|
|
||||||
let isInputFocused = $state(false);
|
let isInputFocused = $state(false);
|
||||||
|
|
||||||
@@ -26,13 +25,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleOnInput() {
|
function handleOnInput() {
|
||||||
if (value.length > 0 && !/^[A-Za-z0-9]*$/.test(value)) {
|
|
||||||
keyError = 'Only alphanumeric characters are allowed';
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
keyError = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
filteredSuggestions = suggestions
|
filteredSuggestions = suggestions
|
||||||
.filter((s) => s.includes(value.toLowerCase()))
|
.filter((s) => s.includes(value.toLowerCase()))
|
||||||
.slice(0, suggestionLimit);
|
.slice(0, suggestionLimit);
|
||||||
@@ -83,9 +75,6 @@
|
|||||||
onfocus={() => (isInputFocused = true)}
|
onfocus={() => (isInputFocused = true)}
|
||||||
onblur={() => (isInputFocused = false)}
|
onblur={() => (isInputFocused = false)}
|
||||||
/>
|
/>
|
||||||
{#if keyError}
|
|
||||||
<p class="mt-1 text-sm text-red-500">{keyError}</p>
|
|
||||||
{/if}
|
|
||||||
<Popover.Root
|
<Popover.Root
|
||||||
open={isOpen}
|
open={isOpen}
|
||||||
disableFocusTrap
|
disableFocusTrap
|
||||||
|
|||||||
Reference in New Issue
Block a user