Skip to content

Commit

Permalink
Dont allow special characters in credential names (#2909)
Browse files Browse the repository at this point in the history
  • Loading branch information
midigofrank authored Feb 6, 2025
1 parent 2bbcccd commit 700c621
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/lightning/credentials/credential.ex
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ defmodule Lightning.Credentials.Credential do
)
|> assoc_constraint(:user)
|> assoc_constraint(:oauth_client)
|> validate_format(:name, ~r/^[a-zA-Z0-9_\- ]*$/,
message: "credential name has invalid format"
)
|> validate_oauth()
|> validate_transfer_ownership()
end
Expand Down
4 changes: 4 additions & 0 deletions test/lightning_web/live/credential_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ defmodule LightningWeb.CredentialLiveTest do
|> form("#credential-form-new", credential: %{name: ""})
|> render_change() =~ "can't be blank"

assert index_live
|> form("#credential-form-new", credential: %{name: "MailChimp'24"})
|> render_change() =~ "credential name has invalid format"

{:ok, _index_live, html} =
index_live
|> form("#credential-form-new", credential: @create_attrs)
Expand Down

0 comments on commit 700c621

Please sign in to comment.