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.

12345678910111213141516171819202122
  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. def is_admin?
  14. head :forbidden unless self.current_user.is_admin
  15. end
  16. end