fly_admin 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/fly_admin/application_controller.rb +1 -1
- data/app/controllers/fly_admin/imbs/application_controller.rb +63 -0
- data/app/controllers/fly_admin/imbs/main_controller.rb +81 -0
- data/app/controllers/fly_admin/imbs/subscriptions_controller.rb +38 -0
- data/app/helpers/fly_admin/imbs/application_helper.rb +31 -0
- data/lib/fly_admin/{connection_api.rb → bornpay/connection_api.rb} +0 -0
- data/lib/fly_admin/imbs/connection_api.rb +24 -0
- data/lib/fly_admin/version.rb +1 -1
- data/lib/fly_admin.rb +4 -4
- metadata +43 -40
- data/app/controllers/fly_admin/subscriptions_controller.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bffa9e90bccfe95f80335440a8393581f198f7ab
|
4
|
+
data.tar.gz: 34047bfcc870a87ef8835bbd489c45f79a9356ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8d0341823a13b4ccd32638b0604740aeea63f61d2cbae3ee19751e640300fe6fcf29f1183a17294bc69fd3bca320beee0f4789710fa50ca2b12806104d05835
|
7
|
+
data.tar.gz: 80e4a167e99617d546d8c7e6a27835c2d31780deb5e152b60317dcb593b0f6a399c5f4b0200d0cab2d5677f37c7563935d6de3536337881a772391adef5b38a9
|
@@ -0,0 +1,63 @@
|
|
1
|
+
class FlyAdmin::Imbs::ApplicationController < ActionController::Base
|
2
|
+
protect_from_forgery
|
3
|
+
|
4
|
+
before_filter :block_user, :store_link_param
|
5
|
+
before_filter :check_user_status, if: Proc.new { user_signed_in? && old_user? }, unless: :devise_controller?
|
6
|
+
before_filter :set_locale, :load_footer
|
7
|
+
|
8
|
+
def block_user
|
9
|
+
render_blocked if session[:blocked]
|
10
|
+
end
|
11
|
+
|
12
|
+
def store_link_param
|
13
|
+
session[:link] = params[:link] if params[:link].present?
|
14
|
+
end
|
15
|
+
|
16
|
+
def check_user_status
|
17
|
+
user_is_valid = FlyAdmin::Imbs::ConnectionApi.check_user(current_user)
|
18
|
+
|
19
|
+
if user_is_valid
|
20
|
+
current_user.update_attributes is_active: true
|
21
|
+
cookies[:active_user] = { value: 1, expires: 1.day.from_now }
|
22
|
+
else
|
23
|
+
current_user.update_attributes is_active: false
|
24
|
+
session[:blocked] = true
|
25
|
+
render_blocked
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def load_footer
|
30
|
+
paysite = session['action_type'] || 'wap'
|
31
|
+
country = I18n.locale.to_s
|
32
|
+
@footer = SiteCache.read("content_#{paysite}_#{country}")
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def old_user?
|
38
|
+
!(current_user.admin? || current_user.tester? || cookies[:active_user].present?)
|
39
|
+
end
|
40
|
+
|
41
|
+
def set_locale
|
42
|
+
locale = params["locale"].try(:downcase).try(:to_sym)
|
43
|
+
I18n.locale = locale && I18n.available_locales.include?(params) ? locale : I18n.default_locale
|
44
|
+
end
|
45
|
+
|
46
|
+
# Locale for all url_helpers in rails
|
47
|
+
def default_url_options(options = {})
|
48
|
+
{ locale: I18n.locale }.merge options
|
49
|
+
end
|
50
|
+
|
51
|
+
def after_sign_in_path_for(resource)
|
52
|
+
root_url
|
53
|
+
end
|
54
|
+
|
55
|
+
def after_sign_out_path_for(resource)
|
56
|
+
root_url
|
57
|
+
end
|
58
|
+
|
59
|
+
def render_blocked
|
60
|
+
render 'errors/blocked', status: :forbidden
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
class FlyAdmin::Imbs::MainController < ActionController::Base
|
2
|
+
skip_before_filter :check_user_status
|
3
|
+
|
4
|
+
def you_blocked
|
5
|
+
end
|
6
|
+
|
7
|
+
def test_request_headers
|
8
|
+
@env = request.env
|
9
|
+
end
|
10
|
+
|
11
|
+
def enter
|
12
|
+
if params[:operation_status] == 'deviceblock'
|
13
|
+
redirect_to "#{root_url}&operation_status=deviceblock" and return
|
14
|
+
end
|
15
|
+
redirect_to paysite_root_url and return unless check_hash!
|
16
|
+
authorize_customer params[:key], params[:pass], params[:login]
|
17
|
+
end
|
18
|
+
|
19
|
+
def authorize_customer(customer_key, password, login)
|
20
|
+
user = User.find_by_login(login)
|
21
|
+
if user.nil?
|
22
|
+
user = User.new(
|
23
|
+
:login => login,
|
24
|
+
:password => password,
|
25
|
+
:customer_key => customer_key
|
26
|
+
)
|
27
|
+
user.save
|
28
|
+
end
|
29
|
+
|
30
|
+
sign_in user unless user_signed_in?
|
31
|
+
flash[:notice] = [ t('your_login') + " #{login}" ]
|
32
|
+
flash[:notice] << "#{t('your_password')} #{password}"
|
33
|
+
|
34
|
+
cookies[:active_user] = { value: 1, expires: 1.day.from_now }
|
35
|
+
|
36
|
+
redirect_to item_link
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def check_hash!
|
42
|
+
true_hash = Digest::MD5.hexdigest(params[:login].to_s + params[:pass].to_s + SiteConfig['wc_service_salt'].to_s)
|
43
|
+
true_hash == params[:hash]
|
44
|
+
end
|
45
|
+
|
46
|
+
def item_link
|
47
|
+
case FlyAdmin.paysite_type
|
48
|
+
when "serials"
|
49
|
+
item_link_for_serials
|
50
|
+
when "news"
|
51
|
+
item_link_for_news
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def paysite_root_url
|
56
|
+
case FlyAdmin.paysite_type
|
57
|
+
when "serials"
|
58
|
+
main_app.root_url
|
59
|
+
when "news"
|
60
|
+
main_app.root_url
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def item_link_for_news
|
65
|
+
if session[:item]
|
66
|
+
item = JSON.parse session[:item]
|
67
|
+
category_article_path(item['category_id'], item['id'])
|
68
|
+
else
|
69
|
+
paysite_root_url
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def item_link_for_serials
|
74
|
+
if session[:item]
|
75
|
+
item = JSON.parse session[:item]
|
76
|
+
category_season_video_path(item['category_id'], item['season_id'], item['id'])
|
77
|
+
else
|
78
|
+
paysite_root_url
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class FlyAdmin::Imbs::SubscriptionsController < ActionController::Base
|
2
|
+
def start
|
3
|
+
save_data_to_session
|
4
|
+
|
5
|
+
link_uuid = session[:link] || SiteConfig['default_uuid']
|
6
|
+
back_url = CGI.escape "http://#{request.host_with_port}/you_blocked"
|
7
|
+
redirect_to "#{SiteConfig['wap_click_addr']}/start/#{link_uuid}?back_url=#{back_url}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def splash
|
11
|
+
begin
|
12
|
+
link = params[:back_url] + "?key=#{params[:customer_key]}"
|
13
|
+
redirect_to link
|
14
|
+
rescue Exception => e
|
15
|
+
SUBSCRIPTION_LOG.error "#{e.message}\n\t#{e.backtrace}"
|
16
|
+
render nothing: true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def save_data_to_session
|
23
|
+
case FlyAdmin.paysite_type
|
24
|
+
when "serials"
|
25
|
+
save_serials_data_to_session
|
26
|
+
when "news"
|
27
|
+
save_news_data_to_session
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def save_serials_data_to_session
|
32
|
+
session[:item] = JSON.generate({ :id => params[:video_id], :category_id => params[:category_id], :season_id => params[:season_id] })
|
33
|
+
end
|
34
|
+
|
35
|
+
def save_news_data_to_session
|
36
|
+
session[:item] = JSON.generate({ :id => params[:item_id], :category_id => params[:category_id] })
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module FlyAdmin::Imbs::ApplicationHelper
|
2
|
+
|
3
|
+
# If anonymous - link to landing page
|
4
|
+
# If customer/admin/etc - link to item page (video#show, article#show etc)
|
5
|
+
|
6
|
+
def item_link(*args)
|
7
|
+
case FlyAdmin.paysite_type
|
8
|
+
when "serials"
|
9
|
+
serials_item_link(*args)
|
10
|
+
when "articles"
|
11
|
+
articles_item_link(*args)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def serials_item_link(category, season, video)
|
16
|
+
if user_signed_in?
|
17
|
+
category_season_video_path(category, season, video)
|
18
|
+
else
|
19
|
+
category_season_video_start_path(category, season, video)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def articles_item_link(category, article)
|
24
|
+
if user_signed_in?
|
25
|
+
category_article_path(category, article)
|
26
|
+
else
|
27
|
+
category_start_path(category, article)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
File without changes
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module FlyAdmin
|
2
|
+
module Imbs
|
3
|
+
class ConnectionApi
|
4
|
+
def self.check_user(user)
|
5
|
+
return true if Rails.env == 'development'
|
6
|
+
|
7
|
+
valid = true
|
8
|
+
begin
|
9
|
+
api_url = SiteConfig['wap_click_addr'] + "/api/check"
|
10
|
+
request = RestClient.get(api_url, :params => {:uuid => user.customer_key, :hash => Digest::MD5.hexdigest(user.customer_key + SiteConfig['wc_service_salt']) })
|
11
|
+
hash = JSON.parse(request).with_indifferent_access
|
12
|
+
|
13
|
+
VALIDATION_LOG.info "status for user #{user.id}: #{hash.inspect}"
|
14
|
+
|
15
|
+
valid = false unless hash[:status].eql? true
|
16
|
+
rescue Exception => e
|
17
|
+
VALIDATION_LOG.error "error check status for user #{user.id}: #{e.message}"
|
18
|
+
end
|
19
|
+
valid
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/fly_admin/version.rb
CHANGED
data/lib/fly_admin.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require "fly_admin/engine"
|
2
2
|
require "fly_admin/page_cache"
|
3
|
-
require "fly_admin/connection_api"
|
3
|
+
require "fly_admin/imbs/connection_api"
|
4
4
|
# require "awesome_print"
|
5
5
|
module FlyAdmin
|
6
|
-
# See
|
7
|
-
mattr_accessor :api_type
|
6
|
+
# See fly_admin initializer for more description
|
7
|
+
mattr_accessor :api_type, :paysite_type
|
8
8
|
mattr_accessor :path
|
9
|
-
end
|
9
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fly_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruslan Korolev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -918,13 +918,16 @@ files:
|
|
918
918
|
- app/controllers/fly_admin/application_controller.rb
|
919
919
|
- app/controllers/fly_admin/categories_controller.rb
|
920
920
|
- app/controllers/fly_admin/footers_controller.rb
|
921
|
+
- app/controllers/fly_admin/imbs/application_controller.rb
|
922
|
+
- app/controllers/fly_admin/imbs/main_controller.rb
|
923
|
+
- app/controllers/fly_admin/imbs/subscriptions_controller.rb
|
921
924
|
- app/controllers/fly_admin/settings_controller.rb
|
922
|
-
- app/controllers/fly_admin/subscriptions_controller.rb
|
923
925
|
- app/controllers/fly_admin/uploads_controller.rb
|
924
926
|
- app/controllers/fly_admin/videos_controller.rb
|
925
927
|
- app/helpers/fly_admin/application_helper.rb
|
926
928
|
- app/helpers/fly_admin/categories_helper.rb
|
927
929
|
- app/helpers/fly_admin/footers_helper.rb
|
930
|
+
- app/helpers/fly_admin/imbs/application_helper.rb
|
928
931
|
- app/helpers/fly_admin/settings_helper.rb
|
929
932
|
- app/helpers/fly_admin/upload_controller_helper.rb
|
930
933
|
- app/helpers/fly_admin/videos_helper.rb
|
@@ -967,8 +970,9 @@ files:
|
|
967
970
|
- db/migrate/20150428102104_add_source_type_to_fly_admin_footers.rb
|
968
971
|
- db/migrate/20150514114816_add_uuid_to_video.rb
|
969
972
|
- lib/fly_admin.rb
|
970
|
-
- lib/fly_admin/connection_api.rb
|
973
|
+
- lib/fly_admin/bornpay/connection_api.rb
|
971
974
|
- lib/fly_admin/engine.rb
|
975
|
+
- lib/fly_admin/imbs/connection_api.rb
|
972
976
|
- lib/fly_admin/page_cache.rb
|
973
977
|
- lib/fly_admin/railtie.rb
|
974
978
|
- lib/fly_admin/version.rb
|
@@ -1056,59 +1060,58 @@ signing_key:
|
|
1056
1060
|
specification_version: 4
|
1057
1061
|
summary: FlyAdmin Rails Engine
|
1058
1062
|
test_files:
|
1059
|
-
- test/
|
1060
|
-
- test/
|
1061
|
-
- test/
|
1062
|
-
- test/
|
1063
|
-
- test/
|
1064
|
-
- test/dummy/app/
|
1063
|
+
- test/integration/navigation_test.rb
|
1064
|
+
- test/helpers/fly_admin/serials_helper_test.rb
|
1065
|
+
- test/helpers/fly_admin/footers_helper_test.rb
|
1066
|
+
- test/helpers/fly_admin/upload_controller_helper_test.rb
|
1067
|
+
- test/lib/generators/fly_admin/install_generator_test.rb
|
1068
|
+
- test/dummy/app/helpers/application_helper.rb
|
1065
1069
|
- test/dummy/app/assets/stylesheets/application.css
|
1070
|
+
- test/dummy/app/assets/javascripts/application.js
|
1066
1071
|
- test/dummy/app/controllers/application_controller.rb
|
1067
|
-
- test/dummy/app/helpers/application_helper.rb
|
1068
1072
|
- test/dummy/app/views/layouts/application.html.erb
|
1069
|
-
- test/dummy/bin/bundle
|
1070
|
-
- test/dummy/bin/rails
|
1071
|
-
- test/dummy/bin/rake
|
1072
|
-
- test/dummy/config/application.rb
|
1073
|
-
- test/dummy/config/boot.rb
|
1074
1073
|
- test/dummy/config/database.yml
|
1075
|
-
- test/dummy/config/
|
1076
|
-
- test/dummy/config/environments/development.rb
|
1074
|
+
- test/dummy/config/locales/en.yml
|
1077
1075
|
- test/dummy/config/environments/production.rb
|
1076
|
+
- test/dummy/config/environments/development.rb
|
1078
1077
|
- test/dummy/config/environments/test.rb
|
1079
|
-
- test/dummy/config/
|
1080
|
-
- test/dummy/config/
|
1078
|
+
- test/dummy/config/routes.rb
|
1079
|
+
- test/dummy/config/environment.rb
|
1081
1080
|
- test/dummy/config/initializers/cookies_serializer.rb
|
1081
|
+
- test/dummy/config/initializers/mime_types.rb
|
1082
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
1083
|
+
- test/dummy/config/initializers/assets.rb
|
1082
1084
|
- test/dummy/config/initializers/filter_parameter_logging.rb
|
1083
1085
|
- test/dummy/config/initializers/inflections.rb
|
1084
|
-
- test/dummy/config/initializers/
|
1086
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
1085
1087
|
- test/dummy/config/initializers/session_store.rb
|
1086
|
-
- test/dummy/config/
|
1087
|
-
- test/dummy/config/
|
1088
|
-
- test/dummy/config/routes.rb
|
1088
|
+
- test/dummy/config/boot.rb
|
1089
|
+
- test/dummy/config/application.rb
|
1089
1090
|
- test/dummy/config/secrets.yml
|
1090
|
-
- test/dummy/config.ru
|
1091
|
-
- test/dummy/db/schema.rb
|
1092
|
-
- test/dummy/public/404.html
|
1093
1091
|
- test/dummy/public/422.html
|
1092
|
+
- test/dummy/public/404.html
|
1094
1093
|
- test/dummy/public/500.html
|
1095
1094
|
- test/dummy/public/favicon.ico
|
1096
1095
|
- test/dummy/Rakefile
|
1097
1096
|
- test/dummy/README.rdoc
|
1098
|
-
- test/
|
1099
|
-
- test/
|
1100
|
-
- test/
|
1097
|
+
- test/dummy/config.ru
|
1098
|
+
- test/dummy/bin/rails
|
1099
|
+
- test/dummy/bin/bundle
|
1100
|
+
- test/dummy/bin/rake
|
1101
|
+
- test/dummy/db/schema.rb
|
1102
|
+
- test/test_helper.rb
|
1103
|
+
- test/controllers/fly_admin/serials_controller_test.rb
|
1104
|
+
- test/controllers/fly_admin/videos_controller_test.rb
|
1105
|
+
- test/controllers/fly_admin/upload_controller_controller_test.rb
|
1106
|
+
- test/controllers/fly_admin/settings_controller_test.rb
|
1107
|
+
- test/controllers/fly_admin/footers_controller_test.rb
|
1101
1108
|
- test/fly_admin_test.rb
|
1102
|
-
- test/helpers/fly_admin/footers_helper_test.rb
|
1103
|
-
- test/helpers/fly_admin/serials_helper_test.rb
|
1104
|
-
- test/helpers/fly_admin/upload_controller_helper_test.rb
|
1105
|
-
- test/integration/navigation_test.rb
|
1106
|
-
- test/jobs/fly_admin/convert_video_job_test.rb
|
1107
|
-
- test/jobs/fly_admin/daemon_control_job_test.rb
|
1108
1109
|
- test/jobs/fly_admin/stop_f_fmpeg_job_test.rb
|
1109
|
-
- test/
|
1110
|
+
- test/jobs/fly_admin/daemon_control_job_test.rb
|
1111
|
+
- test/jobs/fly_admin/convert_video_job_test.rb
|
1112
|
+
- test/models/fly_admin/paysite_test.rb
|
1110
1113
|
- test/models/fly_admin/country_test.rb
|
1111
1114
|
- test/models/fly_admin/footer_test.rb
|
1112
|
-
- test/
|
1113
|
-
- test/
|
1114
|
-
|
1115
|
+
- test/fixtures/fly_admin/footers.yml
|
1116
|
+
- test/fixtures/fly_admin/paysites.yml
|
1117
|
+
- test/fixtures/fly_admin/countries.yml
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module FlyAdmin
|
2
|
-
class SubscriptionsController < ActionController::Base
|
3
|
-
def start
|
4
|
-
get_cookie
|
5
|
-
if @customer_key.present?
|
6
|
-
# video can be in multiple categories , so save category_id
|
7
|
-
session[:video] = JSON.generate({ :id => params[:video_id], :category_id => params[:category_id], :season_id => params[:season_id] })
|
8
|
-
link = "http://#{@alias}/continue?key=#{@customer_key}"
|
9
|
-
redirect_to link
|
10
|
-
else
|
11
|
-
render nothing: true
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def splash
|
16
|
-
begin
|
17
|
-
link = params[:back_url] + "?key=#{params[:customer_key]}"
|
18
|
-
redirect_to link
|
19
|
-
rescue Exception => e
|
20
|
-
SUBSCRIPTION_LOG.error "#{e.message}\n\t#{e.backtrace}"
|
21
|
-
render nothing: true
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def get_cookie
|
28
|
-
if session[:alias]
|
29
|
-
@alias = session[:alias]
|
30
|
-
@customer_key = session[:customer_key]
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|