class SessionsController < ApplicationController skip_before_action :authenticate_user! def auth_request # Manually trigger OmniAuth Steam strategy request.env['omniauth.strategy'] = OmniAuth::Strategies::Steam.new(nil) auth = request.env['omniauth.strategy'].request_phase redirect_to auth end def steam_callback auth_hash = request.env["omniauth.auth"] if auth_hash user = User.find_or_create_from_steam(auth_hash) session[:user_id] = user.id redirect_to dashboard_path, notice: "Logged in successfully!" else redirect_to root_path, alert: "Steam authentication failed." end end def logout session[:user_id] = nil redirect_to root_path, notice: "Logged out successfully!" end end