validate api_entreprise_token

This commit is contained in:
Christophe Robillard 2020-07-08 17:00:21 +02:00
parent c074864c2e
commit 2c56511204
7 changed files with 27 additions and 7 deletions

View file

@ -0,0 +1,9 @@
class JwtTokenValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
begin
JWT.decode value, nil, false
rescue
record.errors[attribute] << (options[:message] || "n'est pas un jeton valide")
end
end
end