digital_heroes_startkit 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +37 -0
- data/Rakefile +36 -0
- data/app/assets/config/digital_heroes_startkit_manifest.js +0 -0
- data/app/assets/javascripts/authorization.coffee +79 -0
- data/app/assets/javascripts/avatar.coffee +16 -0
- data/app/assets/javascripts/datepicker.js +2 -0
- data/app/assets/javascripts/digital_heroes_startkit/cable.js +13 -0
- data/app/assets/javascripts/digital_heroes_startkit/channels/pills.coffee +23 -0
- data/app/assets/javascripts/digital_heroes_startkit/input.coffee +5 -0
- data/app/assets/javascripts/digital_heroes_startkit/pills.coffee +2 -0
- data/app/assets/javascripts/digital_heroes_startkit/snap.svg-min.js +21 -0
- data/app/assets/javascripts/digital_heroes_startkit.js +26 -0
- data/app/assets/javascripts/profile.coffee +53 -0
- data/app/assets/javascripts/profile_geodata.coffee +68 -0
- data/app/assets/javascripts/reg_fields_checkup.coffee +96 -0
- data/app/assets/javascripts/registration.coffee +35 -0
- data/app/assets/javascripts/resurrection.coffee +20 -0
- data/app/channels/application_cable/channel.rb +4 -0
- data/app/channels/application_cable/connection.rb +4 -0
- data/app/channels/pills_channel.rb +10 -0
- data/app/controllers/avatars_controller.rb +11 -0
- data/app/controllers/clients_controller.rb +62 -0
- data/app/controllers/email_access_cards_controller.rb +28 -0
- data/app/controllers/geodata_controller.rb +84 -0
- data/app/controllers/nickname_access_cards_controller.rb +30 -0
- data/app/controllers/oauth_controller.rb +178 -0
- data/app/controllers/openid_controller.rb +124 -0
- data/app/controllers/phone_access_cards_controller.rb +28 -0
- data/app/controllers/profile_controller.rb +114 -0
- data/app/controllers/response_controller.rb +17 -0
- data/app/controllers/start_kit_controller.rb +86 -0
- data/app/controllers/user_cards_controller.rb +305 -0
- data/app/jobs/log_analyzer_job.rb +50 -0
- data/app/jobs/password_resurrection_kill_job.rb +9 -0
- data/app/mailers/admin_mailer.rb +9 -0
- data/app/mailers/client_mailer.rb +3 -0
- data/app/mailers/kreator_mailer.rb +9 -0
- data/app/mailers/manager_mailer.rb +9 -0
- data/app/mailers/prometeus_mailer.rb +16 -0
- data/app/mailers/user_cards_mailer.rb +9 -0
- data/app/models/admin.rb +3 -0
- data/app/models/avatar.rb +23 -0
- data/app/models/city.rb +7 -0
- data/app/models/client.rb +31 -0
- data/app/models/country.rb +7 -0
- data/app/models/delayed_job.rb +20 -0
- data/app/models/email_access_card.rb +30 -0
- data/app/models/kreator.rb +3 -0
- data/app/models/log_error.rb +56 -0
- data/app/models/log_error_type.rb +3 -0
- data/app/models/manager.rb +3 -0
- data/app/models/nickname_access_card.rb +18 -0
- data/app/models/oauth_access_card.rb +38 -0
- data/app/models/phone_access_card.rb +19 -0
- data/app/models/prometeus.rb +50 -0
- data/app/models/user_card.rb +158 -0
- data/app/views/admin_mailer/greetings_email.html.erb +191 -0
- data/app/views/client_mailer/greetings_email.html.erb +191 -0
- data/app/views/kreator_mailer/greetings_email.html.erb +191 -0
- data/app/views/manager_mailer/greetings_email.html.erb +191 -0
- data/app/views/oauth/verify.slim +1 -0
- data/app/views/profile/_add_avatar.slim +12 -0
- data/app/views/profile/_user_profile.slim +95 -0
- data/app/views/profile/index.slim +12 -0
- data/app/views/user_cards/authorization.slim +72 -0
- data/app/views/user_cards/confirmation_but_access_code.slim +7 -0
- data/app/views/user_cards/confirmation_complete.slim +7 -0
- data/app/views/user_cards/registration.slim +86 -0
- data/app/views/user_cards/resurrection.slim +19 -0
- data/app/views/user_cards/resurrection_but_access_code.slim +7 -0
- data/app/views/user_cards/resurrection_no_access_code.slim +7 -0
- data/app/views/user_cards_mailer/email.html.erb +191 -0
- data/app/views/user_cards_mailer/resurrection.html.erb +191 -0
- data/config/initializers/session_manager.rb +2 -0
- data/config/routes.rb +53 -0
- data/lib/access_control.rb +3 -0
- data/lib/digital_heroes_startkit/engine.rb +25 -0
- data/lib/digital_heroes_startkit/version.rb +3 -0
- data/lib/digital_heroes_startkit.rb +5 -0
- data/lib/generators/digital_heroes_startkit/install_generator.rb +61 -0
- data/lib/generators/project/Capfile +36 -0
- data/lib/generators/project/Procfile +3 -0
- data/lib/generators/project/app/assets/stylesheets/application.scss +16 -0
- data/lib/generators/project/app/assets/stylesheets/base/_auth.scss +37 -0
- data/lib/generators/project/app/assets/stylesheets/base/_buttons.scss +62 -0
- data/lib/generators/project/app/assets/stylesheets/base/_checkbox.scss +71 -0
- data/lib/generators/project/app/assets/stylesheets/base/_datepicker.scss +620 -0
- data/lib/generators/project/app/assets/stylesheets/base/_form.scss +81 -0
- data/lib/generators/project/app/assets/stylesheets/base/_notice.scss +14 -0
- data/lib/generators/project/app/assets/stylesheets/base/_pills.scss +39 -0
- data/lib/generators/project/app/assets/stylesheets/base/_profile.scss +67 -0
- data/lib/generators/project/app/assets/stylesheets/base/_reset.scss +49 -0
- data/lib/generators/project/app/assets/stylesheets/base/_social.scss +52 -0
- data/lib/generators/project/app/assets/stylesheets/base/_user.scss +0 -0
- data/lib/generators/project/app/assets/stylesheets/base/_user_avatar.scss +18 -0
- data/lib/generators/project/app/assets/stylesheets/base/styles.scss.txt +35 -0
- data/lib/generators/project/app/assets/stylesheets/plugins/sumoselect.scss +296 -0
- data/lib/generators/project/app/controllers/application_controller.rb +3 -0
- data/lib/generators/project/app/views/layouts/_counts.html.erb +29 -0
- data/lib/generators/project/app/views/layouts/_footer.slim +6 -0
- data/lib/generators/project/app/views/layouts/_head.slim +7 -0
- data/lib/generators/project/app/views/layouts/_header.slim +47 -0
- data/lib/generators/project/app/views/layouts/_mobile_menu.slim +11 -0
- data/lib/generators/project/app/views/layouts/application.slim +26 -0
- data/lib/generators/project/app/views/layouts/mailer.html.erb +13 -0
- data/lib/generators/project/app/views/layouts/mailer.text.erb +1 -0
- data/lib/generators/project/config/application.access.yml +66 -0
- data/lib/generators/project/config/application.db.yml +5 -0
- data/lib/generators/project/config/application.google.yml +3 -0
- data/lib/generators/project/config/application.oauth.yml +135 -0
- data/lib/generators/project/config/application.robokassa.yml +10 -0
- data/lib/generators/project/config/application.sendgrid.yml +3 -0
- data/lib/generators/project/config/application.telegram.yml +22 -0
- data/lib/generators/project/config/application.yml +28 -0
- data/lib/generators/project/config/cable.yml +6 -0
- data/lib/generators/project/config/capistrano.yml +78 -0
- data/lib/generators/project/config/database.yml +52 -0
- data/lib/generators/project/config/deploy/application.secrets.yml +4 -0
- data/lib/generators/project/config/deploy/domain.crt +92 -0
- data/lib/generators/project/config/deploy/domain.key +51 -0
- data/lib/generators/project/config/deploy/nginx.conf +50 -0
- data/lib/generators/project/config/deploy/production.rb +67 -0
- data/lib/generators/project/config/deploy/secrets.yml +32 -0
- data/lib/generators/project/config/deploy/secrets.yml.enc +1 -0
- data/lib/generators/project/config/deploy/secrets.yml.key +1 -0
- data/lib/generators/project/config/deploy/staging.rb +61 -0
- data/lib/generators/project/config/deploy/virgin_conf/database.yml +42 -0
- data/lib/generators/project/config/deploy/virgin_conf/nginx_site.conf +47 -0
- data/lib/generators/project/config/deploy/virgin_conf/nginx_site_ssl.conf +57 -0
- data/lib/generators/project/config/deploy/virgin_conf/postfix.cf +685 -0
- data/lib/generators/project/config/deploy/virgin_conf/production.rb +67 -0
- data/lib/generators/project/config/deploy/virgin_conf/puma.rb +66 -0
- data/lib/generators/project/config/deploy/virgin_sh/capistrano.sh +18 -0
- data/lib/generators/project/config/deploy/virgin_sh/foreman.sh +19 -0
- data/lib/generators/project/config/deploy/virgin_sh/rvm_install.sh +10 -0
- data/lib/generators/project/config/deploy.rb +377 -0
- data/lib/generators/project/config/environments/development.rb +91 -0
- data/lib/generators/project/config/environments/production.rb +142 -0
- data/lib/generators/project/config/initializers/session_store.rb +3 -0
- data/lib/generators/project/config/locales/ru.yml +444 -0
- data/lib/generators/project/db/migrate/10_create_user_cards.rb +19 -0
- data/lib/generators/project/db/migrate/12_create_email_access_cards.rb +15 -0
- data/lib/generators/project/db/migrate/13_create_nickname_access_cards.rb +15 -0
- data/lib/generators/project/db/migrate/14_create_phone_access_cards.rb +16 -0
- data/lib/generators/project/db/migrate/15_create_oauth_access_cards.rb +19 -0
- data/lib/generators/project/db/migrate/1_create_kreators.rb +9 -0
- data/lib/generators/project/db/migrate/21_create_avatars.rb +12 -0
- data/lib/generators/project/db/migrate/30_create_countries.rb +12 -0
- data/lib/generators/project/db/migrate/32_create_cities.rb +12 -0
- data/lib/generators/project/db/migrate/3_create_admins.rb +9 -0
- data/lib/generators/project/db/migrate/44_add_sessions_table.rb +12 -0
- data/lib/generators/project/db/migrate/4_create_managers.rb +10 -0
- data/lib/generators/project/db/migrate/5_create_clients.rb +17 -0
- data/lib/generators/project/db/migrate/60_create_log_error_types.rb +9 -0
- data/lib/generators/project/db/migrate/61_create_log_errors.rb +12 -0
- data/lib/generators/project/db/migrate/78_create_delayed_jobs.rb +22 -0
- data/lib/generators/project/db/seeds.rb +27 -0
- data/lib/generators/project/geodata/cities.csv +25305 -0
- data/lib/generators/project/geodata/countries.csv +250 -0
- data/lib/generators/project/public/401.html +75 -0
- data/lib/generators/project/public/404.html +67 -0
- data/lib/generators/project/public/422.html +67 -0
- data/lib/generators/project/public/500.html +66 -0
- data/lib/generators/project/public/_receiver.html +10 -0
- data/lib/generators/project/public/apple-touch-icon-precomposed.png +0 -0
- data/lib/generators/project/public/apple-touch-icon.png +0 -0
- data/lib/generators/project/public/favicon.ico +0 -0
- data/lib/generators/project/public/robots.txt +1 -0
- data/lib/happy_birthday.rb +5 -0
- data/lib/link.rb +16 -0
- data/lib/oauth/oauth.rb +72 -0
- data/lib/oauth/oauth_fb.rb +48 -0
- data/lib/oauth/oauth_gg.rb +50 -0
- data/lib/oauth/oauth_im.rb +51 -0
- data/lib/oauth/oauth_mr.rb +53 -0
- data/lib/oauth/oauth_vk.rb +3 -0
- data/lib/oauth/oauth_yx.rb +51 -0
- data/lib/openid/openid.rb +46 -0
- data/lib/openid/openid_st.rb +2 -0
- data/lib/phone_cutter.rb +9 -0
- data/lib/response.rb +51 -0
- data/lib/session_manager.rb +47 -0
- data/lib/sms_lib.rb +30 -0
- data/lib/social_networks.rb +328 -0
- data/lib/tasks/digital_heroes_startkit_tasks.rake +83 -0
- data/lib/telegram.rb +33 -0
- metadata +497 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
#
|
2
|
+
# записано fearlessstar / shadows.of.unevenness@gmail.com уже осень
|
3
|
+
#
|
4
|
+
|
5
|
+
document.addEventListener 'turbolinks:load', ->
|
6
|
+
$ ->
|
7
|
+
console.log 'профиль на связи'
|
8
|
+
|
9
|
+
# установка текущей даты
|
10
|
+
$('#birthday').datepicker().val($('.datepicker-here').data('date'))
|
11
|
+
# $('#birthday').datepicker('defaultViewDate', $('.datepicker-here').data('default-view'))
|
12
|
+
|
13
|
+
$('#save-profile').click ->
|
14
|
+
data = {user: {}, user_card: {}}
|
15
|
+
# все филды
|
16
|
+
for field in $('.js-profile .fields')
|
17
|
+
data['user'][field.id] = field.value
|
18
|
+
# все чекбоксы
|
19
|
+
for field in $('.js-profile .checkboxes')
|
20
|
+
data['user'][field.id] = field.checked
|
21
|
+
|
22
|
+
# все селект листы
|
23
|
+
for field in $('.js-profile .select-lists')
|
24
|
+
data['user'][field.id] = field.value
|
25
|
+
|
26
|
+
# отдельная упаковка для юзеркарт которых может быть несколько
|
27
|
+
cards = ['email', 'phone', 'nickname']
|
28
|
+
for cardname in cards
|
29
|
+
data['user_card'][cardname] = []
|
30
|
+
for field in $(".js-profile input[name=field-#{cardname}")
|
31
|
+
data['user_card'][cardname].push {id: $(field).data('id'), value: field.value}
|
32
|
+
# пароль
|
33
|
+
data['user_card']['password'] = $('.js-profile input[name=field-password]').val()
|
34
|
+
# JSON обёртка
|
35
|
+
data['user_card'] = JSON.stringify data['user_card']
|
36
|
+
|
37
|
+
$.ajax(
|
38
|
+
method: 'POST'
|
39
|
+
url: '/profile_update'
|
40
|
+
data: data).done (response) ->
|
41
|
+
console.log response.state
|
42
|
+
console.log response.details
|
43
|
+
$('.enter-notice').removeClass 'active'
|
44
|
+
switch response.state
|
45
|
+
when 'ok'
|
46
|
+
$().user_feedback("blue", 'Данные профиля успешно сохранены')
|
47
|
+
when 'bad'
|
48
|
+
$().reg_errors_default_all()
|
49
|
+
for detail in response.details
|
50
|
+
$('#' + detail + '-notice .enter-notice').addClass 'active'
|
51
|
+
$().user_feedback("red", response.details[0])
|
52
|
+
when 'shit'
|
53
|
+
$().user_feedback("red", response.details[0])
|
@@ -0,0 +1,68 @@
|
|
1
|
+
document.addEventListener 'turbolinks:load', ->
|
2
|
+
$ ->
|
3
|
+
console.log 'геодата профиля на связи'
|
4
|
+
|
5
|
+
delay = 300
|
6
|
+
|
7
|
+
geodata_link = (request, callback, type) ->
|
8
|
+
$.ajax(
|
9
|
+
method: 'POST'
|
10
|
+
url: "/geodata_#{type}"
|
11
|
+
data:
|
12
|
+
name: request.term
|
13
|
+
).done (response) ->
|
14
|
+
switch response.state
|
15
|
+
when 'ok'
|
16
|
+
callback response.haystack
|
17
|
+
when 'shit'
|
18
|
+
console.log response.details[0]
|
19
|
+
$().user_feedback("red", response.details[0])
|
20
|
+
|
21
|
+
country_select = (event, ui) ->
|
22
|
+
$.ajax(
|
23
|
+
method: 'POST'
|
24
|
+
url: "/geodata_set_country"
|
25
|
+
data:
|
26
|
+
country:
|
27
|
+
name: ui.item.value
|
28
|
+
).done (response) ->
|
29
|
+
switch response.state
|
30
|
+
when 'ok'
|
31
|
+
$("#js-autocomplete-cities").val(response.city);
|
32
|
+
$().user_feedback("blue", 'геоданные учтены')
|
33
|
+
when 'shit'
|
34
|
+
console.log response.details[0]
|
35
|
+
$().user_feedback("red", response.details[0])
|
36
|
+
when 'bad'
|
37
|
+
console.log response.details[0]
|
38
|
+
$().user_feedback("red", response.details[0])
|
39
|
+
|
40
|
+
city_select = (event, ui) ->
|
41
|
+
$.ajax(
|
42
|
+
method: 'POST'
|
43
|
+
url: "/geodata_set_city"
|
44
|
+
data:
|
45
|
+
city:
|
46
|
+
name: ui.item.value
|
47
|
+
).done (response) ->
|
48
|
+
switch response.state
|
49
|
+
when 'ok'
|
50
|
+
console.log 'геоданные учтены'
|
51
|
+
# корректировка страны
|
52
|
+
$("#js-autocomplete-countries").val(response.country);
|
53
|
+
$().user_feedback("blue", 'геоданные учтены')
|
54
|
+
when 'shit'
|
55
|
+
console.log response.details[0]
|
56
|
+
$().user_feedback("red", response.details[0])
|
57
|
+
|
58
|
+
$("#js-autocomplete-countries").autocomplete {source: (request, callback) ->
|
59
|
+
geodata_link(request, callback, 'countries')
|
60
|
+
delay: delay
|
61
|
+
select: country_select
|
62
|
+
}
|
63
|
+
|
64
|
+
$("#js-autocomplete-cities").autocomplete {source: (request, callback) ->
|
65
|
+
geodata_link(request, callback, 'cities')
|
66
|
+
delay: delay
|
67
|
+
select: city_select
|
68
|
+
}
|
@@ -0,0 +1,96 @@
|
|
1
|
+
#
|
2
|
+
# записано fearlessstar / shadows.of.unevenness@gmail.com уже осень
|
3
|
+
#
|
4
|
+
|
5
|
+
document.addEventListener 'turbolinks:load', ->
|
6
|
+
$ ->
|
7
|
+
console.log 'проверки полей на связи'
|
8
|
+
|
9
|
+
$.fn.reg_fields = [
|
10
|
+
'nickname',
|
11
|
+
'email',
|
12
|
+
'phone'
|
13
|
+
]
|
14
|
+
|
15
|
+
$.fn.reg_errors_default_all = ->
|
16
|
+
for name in $().reg_fields
|
17
|
+
$().reg_errors_default name
|
18
|
+
$().password_default()
|
19
|
+
|
20
|
+
$.fn.password_default = ->
|
21
|
+
$('#password-notice .error-notice').removeClass 'active'
|
22
|
+
$('#password-notice .warning-notice').removeClass 'active'
|
23
|
+
$('#password-notice .enter-notice').removeClass 'active'
|
24
|
+
$('#password-notice input').removeClass 'success'
|
25
|
+
|
26
|
+
$.fn.reg_errors_default = (name) ->
|
27
|
+
$("##{name}-notice .error-notice").removeClass 'active'
|
28
|
+
$("##{name}-notice .warning-notice").removeClass 'active'
|
29
|
+
$("##{name}-notice .enter-notice").removeClass 'active'
|
30
|
+
$("##{name}-notice input").removeClass 'success'
|
31
|
+
|
32
|
+
delay = 1100
|
33
|
+
password_delay = 1200
|
34
|
+
to = undefined
|
35
|
+
|
36
|
+
password_check = ->
|
37
|
+
$().password_default()
|
38
|
+
|
39
|
+
target = $('input[name="field-password"]')
|
40
|
+
|
41
|
+
$.ajax(
|
42
|
+
method: 'POST'
|
43
|
+
url: '/check_password_line'
|
44
|
+
data:
|
45
|
+
value: target.val()
|
46
|
+
).done (response) ->
|
47
|
+
console.log response.state
|
48
|
+
switch response.state
|
49
|
+
when 'ok'
|
50
|
+
$().password_default()
|
51
|
+
$('#password-notice input').addClass 'success'
|
52
|
+
when 'bad'
|
53
|
+
$('#password-notice .warning-notice').addClass 'active'
|
54
|
+
when 'shit'
|
55
|
+
$('#password-notice .warning-notice').addClass 'active'
|
56
|
+
$().user_feedback("red", response.details[0])
|
57
|
+
|
58
|
+
field_check = (name) ->
|
59
|
+
$().reg_errors_default name
|
60
|
+
target = $("input[name='field-#{name}']")
|
61
|
+
console.log name
|
62
|
+
console.log target.val()
|
63
|
+
$.ajax(
|
64
|
+
method: 'POST'
|
65
|
+
url: '/check_login_by'
|
66
|
+
data:
|
67
|
+
by: name
|
68
|
+
value: target.val()).done (response) ->
|
69
|
+
console.log response
|
70
|
+
switch response.state
|
71
|
+
when 'login'
|
72
|
+
$("##{response.fieldname}-notice .warning-notice").addClass 'active'
|
73
|
+
when 'reg'
|
74
|
+
$().reg_errors_default response.fieldname
|
75
|
+
$("##{response.fieldname}-notice input").addClass 'success'
|
76
|
+
when 'bad_login'
|
77
|
+
$("##{response.fieldname}-notice .error-notice").addClass 'active'
|
78
|
+
|
79
|
+
# камон
|
80
|
+
for name in $().reg_fields
|
81
|
+
$().reg_errors_default name
|
82
|
+
$("input[name='field-#{name}']").unbind 'keyup'
|
83
|
+
|
84
|
+
$("input[name='field-#{name}']").keyup ->
|
85
|
+
name = $(this).data('name')
|
86
|
+
unless typeof to == 'undefined'
|
87
|
+
clearTimeout(to)
|
88
|
+
to = setTimeout (->
|
89
|
+
field_check name
|
90
|
+
), delay
|
91
|
+
|
92
|
+
$('input[name="field-password"]').keyup ->
|
93
|
+
unless typeof password_check.to == 'undefined'
|
94
|
+
clearTimeout(password_check.to)
|
95
|
+
|
96
|
+
password_check.to = setTimeout(password_check, password_delay)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#
|
2
|
+
# записано fearlessstar / shadows.of.unevenness@gmail.com холодным летом 2017, за бортом + 13
|
3
|
+
#
|
4
|
+
|
5
|
+
document.addEventListener 'turbolinks:load', ->
|
6
|
+
$ ->
|
7
|
+
|
8
|
+
console.log 'привет, регистрация на связи'
|
9
|
+
|
10
|
+
$('#reg-button').unbind 'click'
|
11
|
+
$('#reg-button').click ->
|
12
|
+
nickname = $('input[name="field-nickname"]').val()
|
13
|
+
email = $('input[name="field-email"]').val()
|
14
|
+
phone = $('input[name="field-phone"]').val()
|
15
|
+
password = $('input[name="field-password"]').val()
|
16
|
+
|
17
|
+
$.ajax(
|
18
|
+
method: 'POST'
|
19
|
+
url: '/clients'
|
20
|
+
data:
|
21
|
+
client:
|
22
|
+
email: email
|
23
|
+
nickname: nickname
|
24
|
+
phone: phone
|
25
|
+
password: password).done (response) ->
|
26
|
+
console.log "response#{response}"
|
27
|
+
switch response.state
|
28
|
+
when 'ok'
|
29
|
+
window.location.href = response.url
|
30
|
+
when 'bad'
|
31
|
+
$().reg_errors_default_all
|
32
|
+
for detail in response.details
|
33
|
+
$('#' + detail + '-notice .enter-notice').addClass 'active'
|
34
|
+
when 'shit'
|
35
|
+
$().user_feedback("red", response.details[0])
|
@@ -0,0 +1,20 @@
|
|
1
|
+
document.addEventListener 'turbolinks:load', ->
|
2
|
+
$ ->
|
3
|
+
|
4
|
+
console.log 'привет, это вкусный кофе со страницы восстановления пароля.)'
|
5
|
+
|
6
|
+
password_default = ->
|
7
|
+
$('#password-notice .error-notice').removeClass 'active'
|
8
|
+
|
9
|
+
$('#sign-resurrection-button').click ->
|
10
|
+
password_default()
|
11
|
+
$.ajax(
|
12
|
+
method: 'POST'
|
13
|
+
url: '/resurrection_password_update'
|
14
|
+
data:
|
15
|
+
password: $('input[name="field-password"]').val()
|
16
|
+
resurrection_code: $('input[name="resurrection-code"]').val()
|
17
|
+
).done (response) ->
|
18
|
+
switch response.state
|
19
|
+
when 'bad_password' then $('#password-notice .error-notice').addClass 'active'
|
20
|
+
when 'login' then window.location.href = response.url
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file. Action Cable runs in a loop that does not support auto reloading.
|
2
|
+
class PillsChannel < ApplicationCable::Channel
|
3
|
+
def subscribed
|
4
|
+
stream_from "pills"
|
5
|
+
end
|
6
|
+
|
7
|
+
def unsubscribed
|
8
|
+
# Any cleanup needed when channel is unsubscribed
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
class ClientsController < ResponseController
|
2
|
+
|
3
|
+
before_action :set_client, only: [:destroy]
|
4
|
+
before_action :set_params, only: [:create]
|
5
|
+
|
6
|
+
def show
|
7
|
+
@client = Client.find_by(id: params[:id])
|
8
|
+
end
|
9
|
+
|
10
|
+
def create
|
11
|
+
|
12
|
+
begin
|
13
|
+
|
14
|
+
@response.add_detail 'nickname' unless NicknameAccessCard.new({value: @params[:nickname]}).valid?
|
15
|
+
@response.add_detail 'email' unless EmailAccessCard.new({value: @params[:email]}).valid?
|
16
|
+
@response.add_detail 'phone' unless PhoneAccessCard.new({value: @params[:phone]}).valid?
|
17
|
+
@response.add_detail 'password' if @params[:password].to_s.length < 8
|
18
|
+
|
19
|
+
unless @response.details?
|
20
|
+
client = Client.create
|
21
|
+
ActiveRecord::Base.logger.info("client.user_card #{client.user_card}")
|
22
|
+
client.update({name: @params[:name]})
|
23
|
+
|
24
|
+
client.user_card.email_access_cards.create({value: @params[:email]})
|
25
|
+
client.user_card.nickname_access_cards.create({value: @params[:nickname]})
|
26
|
+
client.user_card.phone_access_cards.create({value: @params[:phone]})
|
27
|
+
|
28
|
+
client.user_card.update({password: @params[:password]})
|
29
|
+
# require 'authorizer'
|
30
|
+
# authorizer = Authorizer.new
|
31
|
+
# authorizer.authorize! client.user_card, client.user_card.email_access_cards.first
|
32
|
+
client.user_card.authorize! client.user_card.email_access_cards.first
|
33
|
+
current_user
|
34
|
+
|
35
|
+
@response.set_url profile_path
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
rescue Exception => error
|
40
|
+
p error
|
41
|
+
@response.error_state error.message
|
42
|
+
@response.set_url root_path
|
43
|
+
end
|
44
|
+
|
45
|
+
send_response
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
def destroy
|
50
|
+
@client.destroy
|
51
|
+
redirect_to request.referer
|
52
|
+
end
|
53
|
+
|
54
|
+
def set_client
|
55
|
+
@client = Client.find(params[:id])
|
56
|
+
end
|
57
|
+
|
58
|
+
def set_params
|
59
|
+
@params = params.require(:client).permit(:name, :phone, :email, :nickname, :password)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class EmailAccessCardsController < ApplicationController
|
2
|
+
layout false, only: [:create, :update]
|
3
|
+
before_action :set_access_card, only: [:update, :destroy]
|
4
|
+
|
5
|
+
def create
|
6
|
+
@access_card = EmailAccessCard.new(access_card_params)
|
7
|
+
if @access_card.save
|
8
|
+
@result = :ok
|
9
|
+
else
|
10
|
+
@result = :fail
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def destroy
|
15
|
+
@access_card.destroy
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
# Use callbacks to share common setup or constraints between actions.
|
20
|
+
def set_access_card
|
21
|
+
@access_card = EmailAccessCard.find(params[:id])
|
22
|
+
end
|
23
|
+
|
24
|
+
# Never trust parameters from the scary internet, only allow the white list through.
|
25
|
+
def access_card_params
|
26
|
+
params.require(:email_access_card).permit(:user_id, :value, :active)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
class GeodataController < ResponseController
|
2
|
+
def countries
|
3
|
+
begin
|
4
|
+
raw_haystack = Country.where(["match (name) against (? in boolean mode)", "#{params[:name]}*"]).limit(5)
|
5
|
+
# raw_haystack = Country.where("name LIKE '#{params[:name]}%'").limit(10)
|
6
|
+
haystack = raw_haystack.pluck(:name)
|
7
|
+
|
8
|
+
@response.set_state 'ok'
|
9
|
+
@response.add_var({haystack: haystack})
|
10
|
+
rescue Exception => error
|
11
|
+
@response.error_state error
|
12
|
+
end
|
13
|
+
|
14
|
+
send_response
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
def cities
|
19
|
+
begin
|
20
|
+
country = @current_user.country
|
21
|
+
if country
|
22
|
+
raw_haystack = country.cities.where(["match (name) against (? in boolean mode)", "#{params[:name]}*"]).limit(5)
|
23
|
+
else
|
24
|
+
raw_haystack = City.where(["match (name) against (? in boolean mode)", "#{params[:name]}*"]).limit(5)
|
25
|
+
end
|
26
|
+
haystack = raw_haystack.pluck(:name)
|
27
|
+
|
28
|
+
@response.set_state 'ok'
|
29
|
+
@response.add_var({haystack: haystack})
|
30
|
+
rescue Exception => error
|
31
|
+
@response.error_state error
|
32
|
+
end
|
33
|
+
|
34
|
+
send_response
|
35
|
+
end
|
36
|
+
|
37
|
+
def set_country
|
38
|
+
begin
|
39
|
+
country = Country.find_by(name: params.require(:country)[:name])
|
40
|
+
|
41
|
+
if country
|
42
|
+
@current_user.update(country: country)
|
43
|
+
# обнуление города если страна его не содержит
|
44
|
+
city = nil
|
45
|
+
if @current_user.city.present?
|
46
|
+
if country.cities.ids.include?(@current_user.city.id)
|
47
|
+
city = @current_user.city.name
|
48
|
+
else
|
49
|
+
@current_user.update(city: city)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
@response.add_var ({city: city})
|
53
|
+
@response.set_state 'ok'
|
54
|
+
else
|
55
|
+
@response.add_detail 'страна не найдена в базе данных'
|
56
|
+
end
|
57
|
+
|
58
|
+
rescue Exception => error
|
59
|
+
@response.error_state error
|
60
|
+
end
|
61
|
+
|
62
|
+
send_response
|
63
|
+
end
|
64
|
+
|
65
|
+
def set_city
|
66
|
+
begin
|
67
|
+
city = City.find_by(name: params.require(:city)[:name])
|
68
|
+
|
69
|
+
if city
|
70
|
+
@current_user.update(city: city)
|
71
|
+
@response.set_state 'ok'
|
72
|
+
@response.add_var ({country: @current_user.country.name})
|
73
|
+
else
|
74
|
+
@response.add_detail 'страна не найдена в базе данных'
|
75
|
+
end
|
76
|
+
|
77
|
+
rescue Exception => error
|
78
|
+
@response.error_state error
|
79
|
+
end
|
80
|
+
|
81
|
+
send_response
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class NicknameAccessCardsController < ApplicationController
|
2
|
+
layout false, only: [:create, :update]
|
3
|
+
before_action :set_access_card, only: [:update, :destroy]
|
4
|
+
|
5
|
+
def create
|
6
|
+
if edit_checkout @access_card
|
7
|
+
@access_card = NicknameAccessCard.new(access_card_params)
|
8
|
+
if @access_card.save
|
9
|
+
@result = :ok
|
10
|
+
else
|
11
|
+
@result = :fail
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def destroy
|
17
|
+
@access_card.destroy
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
# Use callbacks to share common setup or constraints between actions.
|
22
|
+
def set_access_card
|
23
|
+
@access_card = NicknameAccessCard.find(params[:id])
|
24
|
+
end
|
25
|
+
|
26
|
+
# Never trust parameters from the scary internet, only allow the white list through.
|
27
|
+
def access_card_params
|
28
|
+
params.require(:nickname_access_card).permit(:user_id, :value, :active)
|
29
|
+
end
|
30
|
+
end
|