module FlyAdmin::Imbs class MainController < ::ApplicationController skip_before_filter :check_user_status def you_blocked flash[:error] = t('service_not_supported') redirect_to paysite_root_url end def test_request_headers @env = request.env end def enter if params[:operation_status] == 'deviceblock' redirect_to "#{root_url}&operation_status=deviceblock" and return end redirect_to paysite_root_url and return unless check_hash! authorize_customer params[:key], params[:pass], params[:login] end def authorize_customer(customer_key, password, login) user = User.find_by_login(login) if user.nil? user = User.new( :login => login, :password => password, :customer_key => customer_key ) user.save end sign_in user unless user_signed_in? flash[:notice] = [ t('your_login') + " #{login}" ] flash[:notice] << "#{t('your_password')} #{password}" cookies[:active_user] = { value: 1, expires: 1.day.from_now } redirect_to item_link end private def check_hash! true_hash = Digest::MD5.hexdigest(params[:login].to_s + params[:pass].to_s + SiteConfig['wc_service_salt'].to_s) true_hash == params[:hash] end def item_link case FlyAdmin.paysite_type when "serials" item_link_for_serials when "news" item_link_for_news end end def paysite_root_url case FlyAdmin.paysite_type when "serials" main_app.root_url when "news" main_app.root_url end end def item_link_for_news if session[:item] item = JSON.parse session[:item] category_article_path(item['category_id'], item['id']) else paysite_root_url end end def item_link_for_serials if session[:item] item = JSON.parse session[:item] category_season_video_path(item['category_id'], item['season_id'], item['id']) else paysite_root_url end end end end