stickers/backend/api/auth.rb
EDRipper 02c297b78f Revert "Merge branch 'main' of https://github.com/hackclub/stickers"
This reverts commit 19e20c9dc7, reversing
changes made to 3693c59a20.

i am once again a goofball
2025-12-07 03:11:24 -05:00

32 lines
621 B
Ruby

# frozen_string_literal: true
class Auth < Grape::API
format :json
helpers SessionHelpers
namespace :auth do
get :login do
redirect '/auth/oidc'
end
get 'oidc/callback' do
auth = env['omniauth.auth']
session[:user] = {
id: auth.uid,
email: auth.info.email,
name: auth.info.name
}
redirect ENV.fetch('AUTH_SUCCESS_REDIRECT', '/')
end
get :logout do
session.clear
redirect ENV.fetch('AUTH_LOGOUT_REDIRECT', '/')
end
get :me do
error!('Unauthorized', 401) unless current_user
current_user
end
end
end