Skip to content

Commit

Permalink
Add uniqueness validation for token string
Browse files Browse the repository at this point in the history
On the database level we already ensure the uniqueness
of the token string through an uniq index. In order to
properly test this in the model specs and to have better
exception handling, the validation should also be present
in the token model.
  • Loading branch information
krauselukas authored and Dany Marcoux committed Apr 26, 2021
1 parent 7f36859 commit 7dca4d5
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/api/app/models/token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Token < ApplicationRecord
has_secure_token :string

validates :user, presence: true
validates :string, uniqueness: { case_sensitive: false }

include Token::Errors

Expand Down

0 comments on commit 7dca4d5

Please sign in to comment.