/
YuriyMaksimov
/
Lab1
Обзор
Документация
Войти
/
YuriyMaksimov
/
Lab1
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
app/controllers/application_controller.rb
17 строк
476 B
Yuriy
auth
20 сен 2025, 09:25
20 сен 2025, 09:25
efb17b1
Код
Авторство
О чём код?
class ApplicationController < ActionController::Base before_action :authorize! private def authorize! header = request.headers['Authorization'] token = header.split(' ').last if header begin decoded = JwtService.decode(token) @current_user = User.find(decoded[:user_id]) rescue StandardError => e render json: { error: e.message }, status: :unauthorized end end end