Performance: Token-based authentication
MEDIUM IMPACT
This affects page load speed and interaction responsiveness by how authentication tokens are handled in requests and responses.
class ApplicationController < ActionController::API before_action :authenticate_user def authenticate_user token = request.headers['Authorization']&.split(' ')&.last payload = JwtService.decode(token) rescue JWT::DecodeError render json: { error: 'Unauthorized' }, status: :unauthorized end end
class ApplicationController < ActionController::API before_action :authenticate_user def authenticate_user token = request.headers['Authorization']&.split(' ')&.last user = User.find_by(token: token) render json: { error: 'Unauthorized' }, status: :unauthorized unless user end end
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Database token lookup per request | N/A | N/A | Blocks rendering until response | [X] Bad |
| Stateless JWT token validation | N/A | N/A | Faster response, less blocking | [OK] Good |