ApiController: check token validity for a given admin

This commit is contained in:
simon lehericey 2018-09-26 15:39:45 +02:00
parent d576d426f4
commit 4a04f2e59f
3 changed files with 43 additions and 42 deletions

View file

@ -43,6 +43,12 @@ class Administrateur < ApplicationRecord
api_token
end
def valid_api_token?(api_token)
BCrypt::Password.new(encrypted_token) == api_token
rescue BCrypt::Errors::InvalidHash
false
end
def registration_state
if active?
'Actif'