vpn_controller.rb 744 B

123456789101112131415161718192021222324
  1. class VpnController < ApplicationController
  2. def openvpn
  3. return if @user.nil?
  4. @accounts = Account.where(:owner => @user["user"])
  5. end
  6. def get_openvpn_config
  7. if @user.nil?
  8. redirect_to "https://login.mephi.ru/login?service=#{url_for(:only_path => false)}.#{params[:format]}" if @user.nil?
  9. return
  10. end
  11. @account = Account.where(:login => params[:login].downcase, :owner => @user["user"]).first
  12. if @account.nil?
  13. render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
  14. end
  15. respond_to do |format|
  16. format.zip { send_data @account.GetOpenVPNConfigZip, :type => 'application/zip' }
  17. format.gz { send_data @account.GetOpenVPNConfigTarGz, :type => 'application/gzip' }
  18. end
  19. end
  20. end