demarches-normaliennes/app/validators/jwt_token_validator.rb
2020-07-08 18:59:22 +02:00

9 lines
258 B
Ruby

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