mirror of
https://github.com/System-End/stickers.git
synced 2026-04-20 00:25:22 +00:00
This reverts commit19e20c9dc7, reversing changes made to3693c59a20. i am once again a goofball
32 lines
621 B
Ruby
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
|