iugusdk 1.0.0.alpha.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (207) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +39 -0
  4. data/app/assets/images/application_logo.png +0 -0
  5. data/app/assets/javascripts/settings.js +10 -0
  6. data/app/assets/javascripts/settings_code.js.coffee.erb +0 -0
  7. data/app/assets/stylesheets/settings.sass +120 -0
  8. data/app/controllers/iugu/account_controller.rb +63 -0
  9. data/app/controllers/iugu/account_domains_controller.rb +64 -0
  10. data/app/controllers/iugu/account_roles_controller.rb +20 -0
  11. data/app/controllers/iugu/account_settings_controller.rb +17 -0
  12. data/app/controllers/iugu/account_users_controller.rb +43 -0
  13. data/app/controllers/iugu/application_domain_controller.rb +11 -0
  14. data/app/controllers/iugu/confirmations_controller.rb +2 -0
  15. data/app/controllers/iugu/invitations_controller.rb +49 -0
  16. data/app/controllers/iugu/omniauth_callbacks_controller.rb +23 -0
  17. data/app/controllers/iugu/passwords_controller.rb +2 -0
  18. data/app/controllers/iugu/profile_controller.rb +44 -0
  19. data/app/controllers/iugu/registrations_controller.rb +3 -0
  20. data/app/controllers/iugu/sessions_controller.rb +2 -0
  21. data/app/controllers/iugu/settings_controller.rb +11 -0
  22. data/app/controllers/iugu/unlocks_controller.rb +2 -0
  23. data/app/mailers/iugu_mailer.rb +16 -0
  24. data/app/models/account.rb +53 -0
  25. data/app/models/account_domain.rb +69 -0
  26. data/app/models/account_role.rb +24 -0
  27. data/app/models/account_user.rb +55 -0
  28. data/app/models/available_language.rb +10 -0
  29. data/app/models/social_account.rb +14 -0
  30. data/app/models/user.rb +107 -0
  31. data/app/models/user_invitation.rb +39 -0
  32. data/app/validators/email_validator.rb +17 -0
  33. data/app/views/iugu-old/account_settings.html.haml +17 -0
  34. data/app/views/iugu-old/login.html.haml +28 -0
  35. data/app/views/iugu-old/mails/confirmation_instructions.html.erb +5 -0
  36. data/app/views/iugu-old/mails/reset_password_instructions.html.erb +8 -0
  37. data/app/views/iugu-old/mails/unlock_instructions.html.erb +7 -0
  38. data/app/views/iugu-old/profile_settings.html.haml +76 -0
  39. data/app/views/iugu-old/signup.html.haml +36 -0
  40. data/app/views/iugu/account_domains/index.html.haml +33 -0
  41. data/app/views/iugu/account_domains/instructions.html.haml +0 -0
  42. data/app/views/iugu/account_roles/edit.html.haml +17 -0
  43. data/app/views/iugu/account_roles/update.html.haml +0 -0
  44. data/app/views/iugu/account_users/index.html.haml +23 -0
  45. data/app/views/iugu/account_users/view.html.haml +0 -0
  46. data/app/views/iugu/confirmations/new.html.haml +8 -0
  47. data/app/views/iugu/invitations/edit.html.haml +8 -0
  48. data/app/views/iugu/invitations/new.html.haml +13 -0
  49. data/app/views/iugu/mailer/confirmation_instructions.html.haml +4 -0
  50. data/app/views/iugu/mailer/invitation.html.haml +1 -0
  51. data/app/views/iugu/mailer/reset_password_instructions.html.haml +4 -0
  52. data/app/views/iugu/mailer/unlock_instructions.html.haml +5 -0
  53. data/app/views/iugu/passwords/edit.html.haml +11 -0
  54. data/app/views/iugu/passwords/new.html.haml +8 -0
  55. data/app/views/iugu/registrations/edit.html.haml +15 -0
  56. data/app/views/iugu/registrations/new.html.haml +11 -0
  57. data/app/views/iugu/sessions/new.html.haml +9 -0
  58. data/app/views/iugu/settings/account.html.haml +48 -0
  59. data/app/views/iugu/settings/accounts.html.haml +33 -0
  60. data/app/views/iugu/settings/profile.html.haml +96 -0
  61. data/app/views/iugu/shared/_links.haml +19 -0
  62. data/app/views/iugu/unlocks/new.html.haml +8 -0
  63. data/app/views/layouts/settings.html.haml +46 -0
  64. data/config/initializers/account_roles.rb +5 -0
  65. data/config/initializers/devise.rb +242 -0
  66. data/config/initializers/social_accounts.rb +16 -0
  67. data/config/locales/devise.en.yml +57 -0
  68. data/config/locales/devise.pt-BR.yml +55 -0
  69. data/config/locales/iugu.en.yml +73 -0
  70. data/config/locales/iugu.pt-BR.yml +73 -0
  71. data/config/routes.rb +77 -0
  72. data/db/migrate/20120528164634_create_account.rb +11 -0
  73. data/db/migrate/20120529134109_add_devise_to_users.rb +53 -0
  74. data/db/migrate/20120529162901_add_birthdate_and_name_to_user.rb +12 -0
  75. data/db/migrate/20120529174755_add_name_and_subscription_id_and_user_id_to_account.rb +13 -0
  76. data/db/migrate/20120529180814_create_account_users.rb +12 -0
  77. data/db/migrate/20120530114709_remove_user_id_from_accounts.rb +9 -0
  78. data/db/migrate/20120531171438_create_account_roles.rb +12 -0
  79. data/db/migrate/20120604131034_add_locale_to_user.rb +9 -0
  80. data/db/migrate/20120605142527_create_social_account.rb +15 -0
  81. data/db/migrate/20120612141130_set_locale.rb +6 -0
  82. data/db/migrate/20120613173114_remove_unique_from_user_email.rb +11 -0
  83. data/db/migrate/20120615180728_create_delayed_jobs.rb +22 -0
  84. data/db/migrate/20120629154429_create_user_invitations.rb +14 -0
  85. data/db/migrate/20120629195345_add_token_to_user_invitations.rb +8 -0
  86. data/db/migrate/20120705202827_add_roles_to_user_invitations.rb +8 -0
  87. data/db/migrate/20120716145846_create_account_domain.rb +14 -0
  88. data/db/migrate/20120719162426_add_subdomain_to_account.rb +9 -0
  89. data/lib/iugusdk.rb +73 -0
  90. data/lib/iugusdk/controllers/helpers.rb +45 -0
  91. data/lib/iugusdk/engine.rb +13 -0
  92. data/lib/iugusdk/locale_filter.rb +12 -0
  93. data/lib/iugusdk/root_tenancy_url.rb +22 -0
  94. data/lib/iugusdk/valid_tenancy_urls.rb +27 -0
  95. data/lib/iugusdk/version.rb +3 -0
  96. data/lib/tasks/iugusdk_tasks.rake +4 -0
  97. data/spec/controller_macros.rb +41 -0
  98. data/spec/controllers/account_controller_spec.rb +155 -0
  99. data/spec/controllers/account_domains_controller_spec.rb +173 -0
  100. data/spec/controllers/account_roles_controller_spec.rb +48 -0
  101. data/spec/controllers/account_settings_controller_spec.rb +42 -0
  102. data/spec/controllers/account_users_controller_spec.rb +145 -0
  103. data/spec/controllers/application_domain_controller_spec.rb +29 -0
  104. data/spec/controllers/invitations_controller_spec.rb +102 -0
  105. data/spec/controllers/profile_controller_spec.rb +125 -0
  106. data/spec/controllers/settings_controller_spec.rb +14 -0
  107. data/spec/dummy/Rakefile +7 -0
  108. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  109. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  110. data/spec/dummy/app/assets/stylesheets/default.sass +111 -0
  111. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  112. data/spec/dummy/app/controllers/dashboard_controller.rb +8 -0
  113. data/spec/dummy/app/controllers/my_dummy_controller.rb +9 -0
  114. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  115. data/spec/dummy/app/views/dashboard/index.html.haml +5 -0
  116. data/spec/dummy/app/views/dashboard/splash.html.haml +10 -0
  117. data/spec/dummy/app/views/layouts/application.html.erb +29 -0
  118. data/spec/dummy/app/views/layouts/dummy.html.erb +22 -0
  119. data/spec/dummy/app/views/my_dummy/index.html.haml +5 -0
  120. data/spec/dummy/config.ru +4 -0
  121. data/spec/dummy/config/account_roles.yml +3 -0
  122. data/spec/dummy/config/application.rb +66 -0
  123. data/spec/dummy/config/boot.rb +10 -0
  124. data/spec/dummy/config/database.yml +37 -0
  125. data/spec/dummy/config/environment.rb +5 -0
  126. data/spec/dummy/config/environments/development.rb +37 -0
  127. data/spec/dummy/config/environments/production.rb +60 -0
  128. data/spec/dummy/config/environments/test.rb +40 -0
  129. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  130. data/spec/dummy/config/initializers/inflections.rb +10 -0
  131. data/spec/dummy/config/initializers/iugusdk.rb +4 -0
  132. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  133. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  134. data/spec/dummy/config/initializers/session_store.rb +8 -0
  135. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  136. data/spec/dummy/config/locales/en.yml +5 -0
  137. data/spec/dummy/config/routes.rb +69 -0
  138. data/spec/dummy/config/social_accounts.yml +6 -0
  139. data/spec/dummy/db/schema.rb +95 -0
  140. data/spec/dummy/public/404.html +26 -0
  141. data/spec/dummy/public/422.html +26 -0
  142. data/spec/dummy/public/500.html +26 -0
  143. data/spec/dummy/public/favicon.ico +0 -0
  144. data/spec/dummy/script/rails +6 -0
  145. data/spec/dummy/tmp/cache/sass/1f198e4a81e57d6c86c6fff1f0e13592b233ebc2/prettify.cssc +0 -0
  146. data/spec/dummy/tmp/cache/sass/40796b6ca2cf9112b889007328d8a4c5fdc634d8/_css3.scssc +0 -0
  147. data/spec/dummy/tmp/cache/sass/40796b6ca2cf9112b889007328d8a4c5fdc634d8/_support.scssc +0 -0
  148. data/spec/dummy/tmp/cache/sass/589e829967f8e21bd017e2d6a46ea53360f10fe0/components.sassc +0 -0
  149. data/spec/dummy/tmp/cache/sass/589e829967f8e21bd017e2d6a46ea53360f10fe0/iugu-ux.sassc +0 -0
  150. data/spec/dummy/tmp/cache/sass/589e829967f8e21bd017e2d6a46ea53360f10fe0/mixins.sassc +0 -0
  151. data/spec/dummy/tmp/cache/sass/589e829967f8e21bd017e2d6a46ea53360f10fe0/reset.sassc +0 -0
  152. data/spec/dummy/tmp/cache/sass/589e829967f8e21bd017e2d6a46ea53360f10fe0/typography.sassc +0 -0
  153. data/spec/dummy/tmp/cache/sass/589e829967f8e21bd017e2d6a46ea53360f10fe0/utilities.sassc +0 -0
  154. data/spec/dummy/tmp/cache/sass/589e829967f8e21bd017e2d6a46ea53360f10fe0/variables.sassc +0 -0
  155. data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_appearance.scssc +0 -0
  156. data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_background-clip.scssc +0 -0
  157. data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_background-origin.scssc +0 -0
  158. data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_background-size.scssc +0 -0
  159. data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_border-radius.scssc +0 -0
  160. data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_box-shadow.scssc +0 -0
  161. data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_box-sizing.scssc +0 -0
  162. data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_box.scssc +0 -0
  163. data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_columns.scssc +0 -0
  164. data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_font-face.scssc +0 -0
  165. data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_images.scssc +0 -0
  166. data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_inline-block.scssc +0 -0
  167. data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_opacity.scssc +0 -0
  168. data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_shared.scssc +0 -0
  169. data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_text-shadow.scssc +0 -0
  170. data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_transform.scssc +0 -0
  171. data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_transition.scssc +0 -0
  172. data/spec/dummy/tmp/cache/sass/9da4e62a062dae83baa33f29455be2ba30cf5dce/_sprites.scssc +0 -0
  173. data/spec/dummy/tmp/cache/sass/db2a23483187bf5625185da2d6f47de2a6de4989/_base.scssc +0 -0
  174. data/spec/dummy/tmp/cache/sass/db2a23483187bf5625185da2d6f47de2a6de4989/_sprite-img.scssc +0 -0
  175. data/spec/dummy/tmp/cache/sass/e5be18dde92936a4632e65289dad5788ed73dd60/base_settings.sassc +0 -0
  176. data/spec/dummy/tmp/cache/sass/e5be18dde92936a4632e65289dad5788ed73dd60/settings.sassc +0 -0
  177. data/spec/dummy/tmp/cache/sass/e764476e9a85279ad82622591ce49983ed21c149/application.sassc +0 -0
  178. data/spec/dummy/tmp/cache/sass/e764476e9a85279ad82622591ce49983ed21c149/base_settings.sassc +0 -0
  179. data/spec/dummy/tmp/cache/sass/e764476e9a85279ad82622591ce49983ed21c149/default.sassc +0 -0
  180. data/spec/dummy/tmp/cache/sass/eab9c0816f626278a6731ce2928de6fdbe99322b/_hacks.scssc +0 -0
  181. data/spec/dummy/tmp/restart.txt +0 -0
  182. data/spec/fabricators/account_domain_fabricator.rb +4 -0
  183. data/spec/fabricators/account_fabricator.rb +4 -0
  184. data/spec/fabricators/account_role_fabricator.rb +3 -0
  185. data/spec/fabricators/account_user_fabricator.rb +4 -0
  186. data/spec/fabricators/social_account_fabricator.rb +10 -0
  187. data/spec/fabricators/user_fabricator.rb +10 -0
  188. data/spec/fabricators/user_invitation_fabricator.rb +4 -0
  189. data/spec/mailers/iugu_mailer_spec.rb +22 -0
  190. data/spec/models/account_domain_spec.rb +111 -0
  191. data/spec/models/account_role_spec.rb +24 -0
  192. data/spec/models/account_spec.rb +155 -0
  193. data/spec/models/account_user_spec.rb +158 -0
  194. data/spec/models/social_account_spec.rb +36 -0
  195. data/spec/models/user_invitation_spec.rb +92 -0
  196. data/spec/models/user_spec.rb +187 -0
  197. data/spec/requests/account_domain_spec.rb +77 -0
  198. data/spec/requests/account_roles_spec.rb +45 -0
  199. data/spec/requests/account_spec.rb +97 -0
  200. data/spec/requests/account_users_spec.rb +129 -0
  201. data/spec/requests/omniauth_spec.rb +79 -0
  202. data/spec/requests/settings_spec.rb +53 -0
  203. data/spec/requests/user_invitation_spec.rb +40 -0
  204. data/spec/requests/user_spec.rb +34 -0
  205. data/spec/spec_helper.rb +116 -0
  206. data/spec/validators/email_validator_spec.rb +21 -0
  207. metadata +729 -0
@@ -0,0 +1,48 @@
1
+ - content_for :title do "Account #{@account.id}" end
2
+
3
+ %br
4
+ %h2
5
+ = I18n.t("iugu.account_settings") + " (##{@account.id})"
6
+
7
+ = simple_form_for @account, :url => account_update_path(:id => @account.id), :method => :put do |f|
8
+ = f.label :name
9
+ = f.text_field :name
10
+ %br
11
+ = f.label :subdomain
12
+ = f.text_field :subdomain
13
+ %br
14
+ = f.submit I18n.t("iugu.save")
15
+
16
+ %br
17
+ Plan Name
18
+ = link_to I18n.t("iugu.change")
19
+
20
+ %br
21
+ %br
22
+ Custom Domains
23
+ = link_to I18n.t("iugu.manage"), account_domains_index_path(@account.id)
24
+ %br
25
+ - if @primary_domain
26
+ Primary:
27
+ = @primary_domain.url
28
+
29
+ %br
30
+ %br
31
+ = link_to I18n.t("iugu.users_and_roles"), account_users_index_path(@account.id)
32
+
33
+ %br
34
+ %br
35
+ = link_to I18n.t("iugu.payment_history")
36
+
37
+ - if current_user.is?(:owner, @account) || current_user.is?(:admin, @account)
38
+ %br
39
+ %br
40
+ - unless @account.destroying?
41
+ = link_to I18n.t("iugu.cancel_account"), account_destroy_path(@account.id), :method => :delete
42
+ - else
43
+ - if IuguSDK::delay_account_exclusion > 0
44
+ = link_to I18n.t("iugu.undo"), account_cancel_destruction_path(@account.id), :method => :delete
45
+ - else
46
+ = I18n.t("iugu.account_destruction_in") + @account.destruction_job.run_at.to_s
47
+
48
+
@@ -0,0 +1,33 @@
1
+ - content_for :title do "Account Settings" end
2
+
3
+ %h3
4
+ = I18n.t "iugu.account_settings"
5
+
6
+ - if current_user.accounts.count > 0
7
+
8
+ %h3
9
+ - if IuguSDK::allow_create_account
10
+ = I18n.t("iugu.accounts")
11
+ - else
12
+ - if current_user.accounts.count > 1
13
+ = I18n.t("iugu.accounts")
14
+ - else
15
+ = I18n.t("iugu.account")
16
+ %div
17
+ = link_to I18n.t("iugu.create_account"), account_create_path, :method => :post
18
+
19
+ - current_user.accounts.each do |account|
20
+ %div
21
+ = account.name
22
+ - if current_user_account.account_id == account.id
23
+ |
24
+ = I18n.t("iugu.active")
25
+ - else
26
+ |
27
+ = link_to I18n.t("iugu.select"), account_select_path(:id => account.id)
28
+ |
29
+ = link_to I18n.t("iugu.settings"), account_view_path(:id => account.id)
30
+
31
+ - else
32
+ %h2
33
+ I dont have any Accounts
@@ -0,0 +1,96 @@
1
+ - content_for :title do "Profile Settings" end
2
+ %div
3
+ %h3
4
+ = I18n.t "iugu.profile_settings"
5
+
6
+ = simple_form_for @user, :url => profile_update_path, :method => :post do |f|
7
+ - if @user.errors.any?
8
+ - unless @user.errors.include?(:password)
9
+ #error_explanation{ :style => "margin-bottom: 15px" }
10
+ %ul
11
+ - @user.errors.full_messages.each do |msg|
12
+ %li
13
+ = msg
14
+
15
+ %div
16
+ = f.label :name
17
+ = f.text_field :name
18
+
19
+ %div
20
+ = f.label :email
21
+ = f.email_field :email
22
+
23
+ %div
24
+ = f.input :birthdate, :as => :date, :start_year => Date.today.year - 5, :end_year => Date.today.year - 100, :order => [:day, :month, :year]
25
+
26
+ %div
27
+ = f.input :locale, :collection => AvailableLanguage.all
28
+
29
+ %div
30
+ = f.submit "OK"
31
+ %br
32
+
33
+ %div
34
+ %h3
35
+ = I18n.t "iugu.change_password"
36
+
37
+ = simple_form_for @user, :url => profile_update_path, :method => :post do |f|
38
+ - if @user.errors.include?(:password)
39
+ #error_explanation{ :style => "margin-bottom: 15px" }
40
+ %ul
41
+ %li
42
+ = "Password " + @user.errors[:password].first
43
+
44
+ %div
45
+ = f.label :password
46
+ = f.password_field :password
47
+
48
+ %div
49
+ = f.label :password_confirmation
50
+ = f.password_field :password_confirmation
51
+
52
+ %div
53
+ = f.submit "OK", :id => "new_password_submit"
54
+
55
+ %div
56
+ - if @user.destroying?
57
+ = I18n.t("iugu.user_destruction_in")
58
+ = @user.destruction_job.run_at
59
+ - unless @user.destruction_job.locked_at
60
+ = link_to I18n.t("iugu.undo"), profile_cancel_destruction_path, :confirm => I18n.t("iugu.are_you_sure?")
61
+ - else
62
+ = link_to I18n.t("iugu.remove_user"), profile_destroy_path, :confirm => I18n.t("iugu.are_you_sure?")
63
+ %br
64
+
65
+ %div
66
+ %h3
67
+ = I18n.t "iugu.social_account"
68
+
69
+ - if flash[:social]
70
+ #error_explanation{ :style => "margin-bottom: 15px" }
71
+ %ul
72
+ %li
73
+ = flash[:social]
74
+
75
+ - @social_accounts.each do |social_account|
76
+
77
+ %div
78
+ = social_account.provider.capitalize
79
+ UID:
80
+ = social_account.social_id
81
+ = link_to "Remove", social_destroy_path(:id => social_account.id)
82
+
83
+ - SOCIAL_ACCOUNTS.keys.each do |provider|
84
+
85
+ - unless @social_accounts.where(:provider => provider).first
86
+ %div
87
+ = link_to "Sign in with #{provider.capitalize}", "/account/auth/#{provider}"
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
@@ -0,0 +1,19 @@
1
+ - if controller_name != 'sessions'
2
+ = link_to "Sign in", new_session_path(resource_name)
3
+ %br/
4
+ - if devise_mapping.registerable? && controller_name != 'registrations'
5
+ = link_to "Sign up", new_registration_path(resource_name)
6
+ %br/
7
+ - if devise_mapping.recoverable? && controller_name != 'passwords'
8
+ = link_to "Forgot your password?", new_password_path(resource_name)
9
+ %br/
10
+ - if devise_mapping.confirmable? && controller_name != 'confirmations'
11
+ = link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name)
12
+ %br/
13
+ - if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks'
14
+ = link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name)
15
+ %br/
16
+ - if devise_mapping.omniauthable?
17
+ - resource_class.omniauth_providers.each do |provider|
18
+ = link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider)
19
+ %br/
@@ -0,0 +1,8 @@
1
+ %h2 Resend unlock instructions
2
+ = simple_form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f|
3
+ = f.error_notification
4
+ .inputs
5
+ = f.input :email, :required => true
6
+ .actions
7
+ = f.button :submit, "Resend unlock instructions"
8
+ = render :partial => "devise/shared/links"
@@ -0,0 +1,46 @@
1
+ !!! 5
2
+ :plain
3
+ <!--[if IE 8 ]><html class="ie8 ie"> <![endif]-->
4
+ <!--[if (gte IE 9)]><html class="ie9 ie"> <![endif]-->
5
+ <!--[if !(IE)]><!--><html><!--<![endif]-->
6
+ %html{:lang => "en"}
7
+ %head
8
+ %meta{:charset => "utf-8"}/
9
+ %title= content_for?(:title) ? (yield(:title) + " - " + IuguSDK::application_title) : I18n.t("iugu.settings")
10
+ = csrf_meta_tags
11
+
12
+ = stylesheet_link_tag "settings"
13
+ = javascript_include_tag "settings"
14
+
15
+ %body{ :class => body_classes.join(' ') + ' settings iugu-ui' }
16
+
17
+
18
+ .header
19
+ = link_to image_tag('application_logo.png'), IuguSDK::app_main_url
20
+
21
+ = link_to I18n.t("iugu.back_to") + IuguSDK::application_title, IuguSDK::app_main_url, :class => "button", :id => "btn-settings-back"
22
+
23
+
24
+ .container
25
+ .wrapper
26
+
27
+ %h1
28
+ = I18n.t("iugu.settings")
29
+ - unless flash[:social]
30
+ - flash.each do |name, msg|
31
+ = content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String)
32
+
33
+
34
+ = link_to I18n.t("iugu.profile"), profile_settings_path
35
+ = ' | '
36
+ - if IuguSDK::allow_create_account == false && current_user.accounts.count <= 1
37
+ = link_to I18n.t("iugu.account"), account_view_path
38
+ - else
39
+ = link_to I18n.t("iugu.accounts"), account_settings_path
40
+
41
+ = yield()
42
+
43
+
44
+
45
+ :plain
46
+ </html>
@@ -0,0 +1,5 @@
1
+ begin
2
+ APP_ROLES = YAML.load_file("#{Rails.root.to_s}/config/account_roles.yml")
3
+ rescue
4
+ APP_ROLES = {"roles"=>["owner", "user"], "owner_role"=>"owner", "admin_role" => "owner" }
5
+ end
@@ -0,0 +1,242 @@
1
+ begin
2
+ SOCIAL_ACCOUNTS = YAML.load_file("#{Rails.root.to_s}/config/social_accounts.yml")
3
+ rescue
4
+ SOCIAL_ACCOUNTS = {}
5
+ end
6
+ #require 'devise'
7
+ # Use this hook to configure devise mailer, warden hooks and so forth.
8
+ # Many of these configuration options can be set straight in your model.
9
+
10
+ Devise.setup do |config|
11
+ # ==> Mailer Configuration
12
+ # Configure the e-mail address which will be shown in Devise::Mailer,
13
+ # note that it will be overwritten if you use your own mailer class with default "from" parameter.
14
+ config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
15
+
16
+ # Configure the class responsible to send e-mails.
17
+ config.mailer = "Devise::Mailer"
18
+
19
+ # ==> ORM configuration
20
+ # Load and configure the ORM. Supports :active_record (default) and
21
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
22
+ # available as additional gems.
23
+ require 'devise/orm/active_record'
24
+
25
+ # ==> Configuration for any authentication mechanism
26
+ # Configure which keys are used when authenticating a user. The default is
27
+ # just :email. You can configure it to use [:username, :subdomain], so for
28
+ # authenticating a user, both parameters are required. Remember that those
29
+ # parameters are used only when authenticating and not when retrieving from
30
+ # session. If you need permissions, you should implement that in a before filter.
31
+ # You can also supply a hash where the value is a boolean determining whether
32
+ # or not authentication should be aborted when the value is not present.
33
+ # config.authentication_keys = [ :email ]
34
+
35
+ # Configure parameters from the request object used for authentication. Each entry
36
+ # given should be a request method and it will automatically be passed to the
37
+ # find_for_authentication method and considered in your model lookup. For instance,
38
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
39
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
40
+ # config.request_keys = []
41
+
42
+ # Configure which authentication keys should be case-insensitive.
43
+ # These keys will be downcased upon creating or modifying a user and when used
44
+ # to authenticate or find a user. Default is :email.
45
+ config.case_insensitive_keys = [ :email ]
46
+
47
+ # Configure which authentication keys should have whitespace stripped.
48
+ # These keys will have whitespace before and after removed upon creating or
49
+ # modifying a user and when used to authenticate or find a user. Default is :email.
50
+ config.strip_whitespace_keys = [ :email ]
51
+
52
+ # Tell if authentication through request.params is enabled. True by default.
53
+ # It can be set to an array that will enable params authentication only for the
54
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
55
+ # enable it only for database (email + password) authentication.
56
+ # config.params_authenticatable = true
57
+
58
+ # Tell if authentication through HTTP Basic Auth is enabled. False by default.
59
+ # It can be set to an array that will enable http authentication only for the
60
+ # given strategies, for example, `config.http_authenticatable = [:token]` will
61
+ # enable it only for token authentication.
62
+ # config.http_authenticatable = false
63
+
64
+ # If http headers should be returned for AJAX requests. True by default.
65
+ # config.http_authenticatable_on_xhr = true
66
+
67
+ # The realm used in Http Basic Authentication. "Application" by default.
68
+ # config.http_authentication_realm = "Application"
69
+
70
+ # It will change confirmation, password recovery and other workflows
71
+ # to behave the same regardless if the e-mail provided was right or wrong.
72
+ # Does not affect registerable.
73
+ # config.paranoid = true
74
+
75
+ # By default Devise will store the user in session. You can skip storage for
76
+ # :http_auth and :token_auth by adding those symbols to the array below.
77
+ # Notice that if you are skipping storage for all authentication paths, you
78
+ # may want to disable generating routes to Devise's sessions controller by
79
+ # passing :skip => :sessions to `devise_for` in your config/routes.rb
80
+ config.skip_session_storage = [:http_auth]
81
+
82
+ # ==> Configuration for :database_authenticatable
83
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
84
+ # using other encryptors, it sets how many times you want the password re-encrypted.
85
+ #
86
+ # Limiting the stretches to just one in testing will increase the performance of
87
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
88
+ # a value less than 10 in other environments.
89
+ config.stretches = Rails.env.test? ? 1 : 10
90
+
91
+ # Setup a pepper to generate the encrypted password.
92
+ # config.pepper = "60cc0cf4c8cf54b8da0e0d2f91382be6764aabcd814d1fed26a382d71d103cee51de246592437bd862a45eba83d4ccae42422bd599e638989b09dc9ef2c70c9b"
93
+
94
+ # ==> Configuration for :confirmable
95
+ # A period that the user is allowed to access the website even without
96
+ # confirming his account. For instance, if set to 2.days, the user will be
97
+ # able to access the website for two days without confirming his account,
98
+ # access will be blocked just in the third day. Default is 0.days, meaning
99
+ # the user cannot access the website without confirming his account.
100
+ # config.allow_unconfirmed_access_for = 2.days
101
+
102
+ # If true, requires any email changes to be confirmed (exactly the same way as
103
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
104
+ # db field (see migrations). Until confirmed new email is stored in
105
+ # unconfirmed email column, and copied to email column on successful confirmation.
106
+ # config.reconfirmable = true
107
+
108
+ # Defines which key will be used when confirming an account
109
+ # config.confirmation_keys = [ :email ]
110
+
111
+ # ==> Configuration for :rememberable
112
+ # The time the user will be remembered without asking for credentials again.
113
+ # config.remember_for = 2.weeks
114
+
115
+ # If true, extends the user's remember period when remembered via cookie.
116
+ # config.extend_remember_period = false
117
+
118
+ # Options to be passed to the created cookie. For instance, you can set
119
+ # :secure => true in order to force SSL only cookies.
120
+ # config.rememberable_options = {}
121
+
122
+ # ==> Configuration for :validatable
123
+ # Range for password length. Default is 6..128.
124
+ # config.password_length = 6..128
125
+
126
+ # Email regex used to validate email formats. It simply asserts that
127
+ # an one (and only one) @ exists in the given string. This is mainly
128
+ # to give user feedback and not to assert the e-mail validity.
129
+ # config.email_regexp = /\A[^@]+@[^@]+\z/
130
+
131
+ # ==> Configuration for :timeoutable
132
+ # The time you want to timeout the user session without activity. After this
133
+ # time the user will be asked for credentials again. Default is 30 minutes.
134
+ # config.timeout_in = 30.minutes
135
+
136
+ # ==> Configuration for :lockable
137
+ # Defines which strategy will be used to lock an account.
138
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
139
+ # :none = No lock strategy. You should handle locking by yourself.
140
+ # config.lock_strategy = :failed_attempts
141
+
142
+ # Defines which key will be used when locking and unlocking an account
143
+ # config.unlock_keys = [ :email ]
144
+
145
+ # Defines which strategy will be used to unlock an account.
146
+ # :email = Sends an unlock link to the user email
147
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
148
+ # :both = Enables both strategies
149
+ # :none = No unlock strategy. You should handle unlocking by yourself.
150
+ # config.unlock_strategy = :both
151
+
152
+ # Number of authentication tries before locking an account if lock_strategy
153
+ # is failed attempts.
154
+ # config.maximum_attempts = 20
155
+
156
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
157
+ # config.unlock_in = 1.hour
158
+
159
+ # ==> Configuration for :recoverable
160
+ #
161
+ # Defines which key will be used when recovering the password for an account
162
+ # config.reset_password_keys = [ :email ]
163
+
164
+ # Time interval you can reset your password with a reset password key.
165
+ # Don't put a too small interval or your users won't have the time to
166
+ # change their passwords.
167
+ config.reset_password_within = 6.hours
168
+
169
+ # ==> Configuration for :encryptable
170
+ # Allow you to use another encryption algorithm besides bcrypt (default). You can use
171
+ # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
172
+ # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
173
+ # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
174
+ # REST_AUTH_SITE_KEY to pepper)
175
+ # config.encryptor = :sha512
176
+
177
+ # ==> Configuration for :token_authenticatable
178
+ # Defines name of the authentication token params key
179
+ # config.token_authentication_key = :auth_token
180
+
181
+ # ==> Scopes configuration
182
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
183
+ # "users/sessions/new". It's turned off by default because it's slower if you
184
+ # are using only default views.
185
+ # config.scoped_views = false
186
+
187
+ # Configure the default scope given to Warden. By default it's the first
188
+ # devise role declared in your routes (usually :user).
189
+ # config.default_scope = :user
190
+
191
+ # Configure sign_out behavior.
192
+ # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
193
+ # The default is true, which means any logout action will sign out all active scopes.
194
+ # config.sign_out_all_scopes = true
195
+
196
+ # ==> Navigation configuration
197
+ # Lists the formats that should be treated as navigational. Formats like
198
+ # :html, should redirect to the sign in page when the user does not have
199
+ # access, but formats like :xml or :json, should return 401.
200
+ #
201
+ # If you have any extra navigational formats, like :iphone or :mobile, you
202
+ # should add them to the navigational formats lists.
203
+ #
204
+ # The "*/*" below is required to match Internet Explorer requests.
205
+ # config.navigational_formats = ["*/*", :html]
206
+
207
+ # The default HTTP method used to sign out a resource. Default is :delete.
208
+ config.sign_out_via = :delete
209
+
210
+ # ==> OmniAuth
211
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
212
+ # up on your models and hooks.
213
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
214
+
215
+ SOCIAL_ACCOUNTS.keys.each do |provider_name|
216
+ config.omniauth provider_name.to_sym, SOCIAL_ACCOUNTS[provider_name]['token'], SOCIAL_ACCOUNTS[provider_name]['secret']
217
+ end
218
+
219
+
220
+ # ==> Warden configuration
221
+ # If you want to use other strategies, that are not supported by Devise, or
222
+ # change the failure app, you can configure them inside the config.warden block.
223
+ #
224
+ # config.warden do |manager|
225
+ # manager.intercept_401 = false
226
+ # manager.default_strategies(:scope => :user).unshift :some_external_strategy
227
+ # end
228
+
229
+ end
230
+
231
+ Warden::Manager.after_authentication do |record,auth,opts|
232
+ if record && record.respond_to?(:accounts)
233
+ include IuguSDK::Controllers::Helpers
234
+ cookie_name = 'account'
235
+ account = record.default_account( auth.cookies['last_' + cookie_name + '_id'] )
236
+ if account
237
+ auth.cookies['last_' + cookie_name.downcase + '_id'] = { :value => account.id, :expires => 365.days.from_now }
238
+ auth.env['rack.session'][ 'current_' + cookie_name.downcase + '_id' ] = account.id
239
+ end
240
+ end
241
+ end
242
+