API de comptabilité horaire.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

authenticable.rb 380B

123456789101112131415161718
  1. module Authenticable
  2. def current_user
  3. return @current_user if @current_user
  4. header = request.headers['Authorization']
  5. return nil if header.nil?
  6. decoded = JsonWebToken.decode(header)
  7. @current_user = User.find(decoded[:user_id]) rescue ActiveRecord::RecordNotFound
  8. end
  9. protected
  10. def check_login
  11. head :forbidden unless self.current_user
  12. end
  13. end