Websites/app/controllers/yiff_rest/api_v2/application_controller.rb
Donovan Daniels b1c702e3cd
Add image management ui
poorly tested but it worked well enough, I'm sure I'll be patching bugs over the next few weeks
Also remove turbo because it sucks
Also changed the way we handle hosts in dev
2024-05-06 03:25:17 -05:00

25 lines
838 B
Ruby

# frozen_string_literal: true
module YiffRest
module APIV2
class ApplicationController < ::YiffRest::ApplicationController
protected
def site_domain
YiffRestRoutes::V2_DOMAIN
end
def validate_discord
redirect_to(Websites.config.yiffyapi_discord_redirect("manage_images"), allow_other_host: true) if session[:discord_user].blank?
end
def prepare_user
name = session.dig("discord_user", "global_name") || "#{session.dig('discord_user', 'username')}#{@session.dig('discord_user', 'discriminator')}"
CurrentUser.user = APIUser.find_or_create_by(id: session.dig("discord_user", "id"))
CurrentUser.update!(name: name, discord_data: session["discord_user"])
CurrentUser.update_avatar(session.dig("discord_user", "avatar"))
end
end
end
end