validate api_entreprise_token
This commit is contained in:
parent
c074864c2e
commit
2c56511204
7 changed files with 27 additions and 7 deletions
9
app/validators/jwt_token_validator.rb
Normal file
9
app/validators/jwt_token_validator.rb
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue