demarches-normaliennes/app/validators/jwt_token_validator.rb
2023-05-03 11:35:29 +02:00

9 lines
278 B
Ruby

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