hello-rails 0.0.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +20 -0
- data/README.md +97 -0
- data/Rakefile +23 -0
- data/app/controllers/hello/application_controller.rb +27 -0
- data/app/controllers/hello/authentication/sessions_controller.rb +81 -0
- data/app/controllers/hello/authentication/sign_in_controller.rb +39 -0
- data/app/controllers/hello/authentication/sudo_mode_controller.rb +40 -0
- data/app/controllers/hello/concerns/authentication/sign_in.rb +44 -0
- data/app/controllers/hello/concerns/management/forgot_password.rb +45 -0
- data/app/controllers/hello/concerns/management/reset_password.rb +33 -0
- data/app/controllers/hello/concerns/registration/sign_up.rb +64 -0
- data/app/controllers/hello/internationalization/locale_controller.rb +28 -0
- data/app/controllers/hello/management/accesses_controller.rb +29 -0
- data/app/controllers/hello/management/confirm_emails_controller.rb +41 -0
- data/app/controllers/hello/management/emails_controller.rb +67 -0
- data/app/controllers/hello/management/forgot_password_controller.rb +41 -0
- data/app/controllers/hello/management/passwords_controller.rb +57 -0
- data/app/controllers/hello/management/profiles_controller.rb +71 -0
- data/app/controllers/hello/management/reset_password_controller.rb +53 -0
- data/app/controllers/hello/registration/sign_up_controller.rb +63 -0
- data/app/helpers/hello/application_helper.rb +5 -0
- data/app/mailers/hello/mailer.rb +26 -0
- data/app/models/access.rb +2 -0
- data/app/models/credential.rb +2 -0
- data/app/models/email_credential.rb +2 -0
- data/app/models/password_credential.rb +2 -0
- data/app/models/user.rb +2 -0
- data/app/views/hello/authentication/_sign_in.html.erb +64 -0
- data/app/views/hello/authentication/new_session.html.erb +4 -0
- data/app/views/hello/authentication/sessions.html.erb +36 -0
- data/app/views/hello/authentication/sign_in.html.erb +3 -0
- data/app/views/hello/authentication/sudo_mode.html.erb +37 -0
- data/app/views/hello/internationalization/locales.html.erb +7 -0
- data/app/views/hello/mailer/confirm_email.html.erb +12 -0
- data/app/views/hello/mailer/forgot_password.html.erb +12 -0
- data/app/views/hello/mailer/welcome.html.erb +11 -0
- data/app/views/hello/management/accesses.html.erb +47 -0
- data/app/views/hello/management/cancel.html.erb +14 -0
- data/app/views/hello/management/email_credentials/expired_confirmation_token.html.erb +1 -0
- data/app/views/hello/management/email_credentials/index.html.erb +84 -0
- data/app/views/hello/management/password_credentials/_forgot_form.html.erb +17 -0
- data/app/views/hello/management/password_credentials/_reset_form.html.erb +39 -0
- data/app/views/hello/management/password_credentials/forgot.html.erb +10 -0
- data/app/views/hello/management/password_credentials/forgot_success.html.erb +26 -0
- data/app/views/hello/management/password_credentials/reset.html.erb +3 -0
- data/app/views/hello/management/password_credentials/show.html.erb +25 -0
- data/app/views/hello/management/user.html.erb +73 -0
- data/app/views/hello/registration/_sign_up.html.erb +86 -0
- data/app/views/hello/registration/sign_up.html.erb +3 -0
- data/app/views/hello/registration/sign_up_widget.html.erb +3 -0
- data/app/views/hello/shared/_errors.html.erb +11 -0
- data/app/views/hello/shared/_flash.html.erb +8 -0
- data/app/views/hello/shared/_nav_pills.html.erb +15 -0
- data/app/views/hello/shared/_session_expiration.html.erb +15 -0
- data/app/views/hello/shared/_settings.html.erb +41 -0
- data/config/locales/hello.en.yml +69 -0
- data/config/locales/hello.es.yml +71 -0
- data/config/locales/hello.fr.yml +71 -0
- data/config/locales/hello.pl.yml +71 -0
- data/config/locales/hello.pt-BR.yml +71 -0
- data/config/locales/hello.zh-CN.yml +71 -0
- data/config/locales/hello.zh-TW.yml +71 -0
- data/config/routes.rb +74 -0
- data/db/migrate/1_create_credentials.rb +17 -0
- data/db/migrate/2_create_accesses.rb +15 -0
- data/db/migrate/3_create_users.rb +23 -0
- data/lib/generators/hello/concerns/USAGE +8 -0
- data/lib/generators/hello/concerns/concerns_generator.rb +10 -0
- data/lib/generators/hello/from_devise/USAGE +8 -0
- data/lib/generators/hello/from_devise/from_devise_generator.rb +13 -0
- data/lib/generators/hello/from_devise/templates/from_devise.migration.rb +39 -0
- data/lib/generators/hello/install/USAGE +8 -0
- data/lib/generators/hello/install/install_generator.rb +94 -0
- data/lib/generators/hello/install/templates/application.html.erb +35 -0
- data/lib/generators/hello/install/templates/hello_helper.rb +16 -0
- data/lib/generators/hello/install/templates/initializer.rb +24 -0
- data/lib/generators/hello/install/templates/models/concerns/user/authorization.rb +21 -0
- data/lib/generators/hello/install/templates/models/user.rb +9 -0
- data/lib/generators/hello/install/templates/onboarding/index.html.erb +5 -0
- data/lib/generators/hello/install/templates/onboarding/onboarding_controller.rb +33 -0
- data/lib/generators/hello/install/templates/root/index.html.erb +7 -0
- data/lib/generators/hello/install/templates/root/root_controller.rb +6 -0
- data/lib/generators/hello/install/templates/users/controllers/users_controller.rb +71 -0
- data/lib/generators/hello/install/templates/users/views/users/index.html.erb +29 -0
- data/lib/generators/hello/install/templates/users/views/users/list.html.erb +35 -0
- data/lib/generators/hello/install/templates/users/views/users/new.html.erb +60 -0
- data/lib/generators/hello/install/templates/users/views/users/show.html.erb +74 -0
- data/lib/generators/hello/locales/USAGE +12 -0
- data/lib/generators/hello/locales/locales_generator.rb +64 -0
- data/lib/generators/hello/views/USAGE +8 -0
- data/lib/generators/hello/views/views_generator.rb +9 -0
- data/lib/hello-rails.rb +1 -0
- data/lib/hello.rb +36 -0
- data/lib/hello/CHANGES.md +26 -0
- data/lib/hello/business.rb +47 -0
- data/lib/hello/business/authentication/sign_in.rb +92 -0
- data/lib/hello/business/authentication/sign_out.rb +8 -0
- data/lib/hello/business/authentication/sudo_mode_authentication.rb +25 -0
- data/lib/hello/business/authentication/sudo_mode_expiration.rb +17 -0
- data/lib/hello/business/base.rb +33 -0
- data/lib/hello/business/internationalization/update_locale.rb +33 -0
- data/lib/hello/business/management/add_email.rb +19 -0
- data/lib/hello/business/management/cancel_account.rb +22 -0
- data/lib/hello/business/management/confirm_email.rb +36 -0
- data/lib/hello/business/management/forgot_password.rb +47 -0
- data/lib/hello/business/management/remove_email.rb +19 -0
- data/lib/hello/business/management/reset_password.rb +34 -0
- data/lib/hello/business/management/send_confirmation_email.rb +40 -0
- data/lib/hello/business/management/unlink_access.rb +8 -0
- data/lib/hello/business/management/update_profile.rb +44 -0
- data/lib/hello/business/registration/sign_up.rb +159 -0
- data/lib/hello/configuration.rb +12 -0
- data/lib/hello/encryptors.rb +6 -0
- data/lib/hello/encryptors/complex.rb +25 -0
- data/lib/hello/encryptors/simple.rb +27 -0
- data/lib/hello/engine.rb +23 -0
- data/lib/hello/errors.rb +12 -0
- data/lib/hello/locales.rb +238 -0
- data/lib/hello/middleware.rb +13 -0
- data/lib/hello/rails_active_record.rb +10 -0
- data/lib/hello/rails_active_record/access.rb +65 -0
- data/lib/hello/rails_active_record/credential.rb +51 -0
- data/lib/hello/rails_active_record/email_credential.rb +60 -0
- data/lib/hello/rails_active_record/password_credential.rb +70 -0
- data/lib/hello/rails_active_record/user.rb +99 -0
- data/lib/hello/rails_controller.rb +124 -0
- data/lib/hello/rails_controller/restrict_by_role.rb +79 -0
- data/lib/hello/rails_helper.rb +35 -0
- data/lib/hello/request_manager.rb +14 -0
- data/lib/hello/request_manager/abstract.rb +77 -0
- data/lib/hello/request_manager/factory.rb +32 -0
- data/lib/hello/request_manager/stateful.rb +53 -0
- data/lib/hello/request_manager/stateful/finder.rb +58 -0
- data/lib/hello/request_manager/stateful/session_wrapper.rb +37 -0
- data/lib/hello/request_manager/stateless.rb +35 -0
- data/lib/hello/time_zones.rb +7 -0
- data/lib/hello/utils.rb +11 -0
- data/lib/hello/utils/device_name.rb +34 -0
- data/lib/hello/version.rb +4 -0
- data/lib/tasks/hello_tasks.rake +4 -0
- data/spec/bdd/hello/authentication/authorization/authorization_role_restriction_spec.rb +291 -0
- data/spec/bdd/hello/authentication/authorization/authorization_router_constraints_spec.rb +41 -0
- data/spec/bdd/hello/authentication/authorization/authorization_sensitive_restriction_spec.rb +84 -0
- data/spec/bdd/hello/authentication/authorization/bdd.yml +1 -0
- data/spec/bdd/hello/authentication/bdd.yml +1 -0
- data/spec/bdd/hello/authentication/classic_sign_in_spec.rb +264 -0
- data/spec/bdd/hello/authentication/manage_sessions_spec.rb +292 -0
- data/spec/bdd/hello/authentication/sign_out_spec.rb +159 -0
- data/spec/bdd/hello/bdd.yml +1 -0
- data/spec/bdd/hello/internalionalization/anyone_can_change_their_locale/bdd.yml +1 -0
- data/spec/bdd/hello/internalionalization/anyone_can_change_their_locale/change_locale_on_the_locale_page_spec.rb +90 -0
- data/spec/bdd/hello/internalionalization/anyone_can_change_their_locale/change_locale_on_the_profile_page_spec.rb +64 -0
- data/spec/bdd/hello/internalionalization/anyone_can_change_their_locale/change_locale_on_the_sign_in_form_spec.rb +31 -0
- data/spec/bdd/hello/internalionalization/anyone_can_change_their_locale/change_locale_on_the_sign_up_form_spec.rb +34 -0
- data/spec/bdd/hello/internalionalization/anyone_can_change_their_timezone/bdd.yml +1 -0
- data/spec/bdd/hello/internalionalization/anyone_can_change_their_timezone/change_timezone_on_the_profile_page_spec.rb +14 -0
- data/spec/bdd/hello/internalionalization/anyone_can_change_their_timezone/change_timezone_on_the_sign_in_form_spec.rb +14 -0
- data/spec/bdd/hello/internalionalization/anyone_can_change_their_timezone/change_timezone_on_the_sign_up_form_spec.rb +14 -0
- data/spec/bdd/hello/internalionalization/bdd.yml +1 -0
- data/spec/bdd/hello/management/bdd.yml +1 -0
- data/spec/bdd/hello/management/cancel_account_spec.rb +128 -0
- data/spec/bdd/hello/management/manage_email_credentials/bdd.yml +1 -0
- data/spec/bdd/hello/management/manage_email_credentials/manage_email_credentials_emails_api_spec.rb +7 -0
- data/spec/bdd/hello/management/manage_email_credentials/manage_email_credentials_emails_page_spec.rb +252 -0
- data/spec/bdd/hello/management/manage_password_credentials/bdd.yml +1 -0
- data/spec/bdd/hello/management/manage_password_credentials/manage_password_forgot_password_spec.rb +68 -0
- data/spec/bdd/hello/management/manage_password_credentials/manage_password_page_spec.rb +60 -0
- data/spec/bdd/hello/management/manage_password_credentials/manage_password_reset_password_spec.rb +145 -0
- data/spec/bdd/hello/management/manage_profile/bdd.yml +1 -0
- data/spec/bdd/hello/management/manage_profile/manage_profile_api_spec.rb +7 -0
- data/spec/bdd/hello/management/manage_profile/manage_profile_page_spec.rb +65 -0
- data/spec/bdd/hello/management/manage_social_credentials/bdd.yml +1 -0
- data/spec/bdd/hello/management/manage_social_credentials/manage_social_credentials_pending_spec.rb +7 -0
- data/spec/bdd/hello/management/unlink_sessions_spec.rb +59 -0
- data/spec/bdd/hello/other/bdd.yml +1 -0
- data/spec/bdd/hello/other/create_user_spec.rb +70 -0
- data/spec/bdd/hello/other/impersonate_user_spec.rb +58 -0
- data/spec/bdd/hello/other/list_users_spec.rb +86 -0
- data/spec/bdd/hello/registration/bdd.yml +1 -0
- data/spec/bdd/hello/registration/classic_sign_up_spec.rb +228 -0
- data/spec/bdd/hello/registration/onboarding_process_spec.rb +101 -0
- data/spec/bdd/hello/support.rb +62 -0
- data/spec/business/hello/authentication/sign_in_spec.rb +72 -0
- data/spec/business/hello/registration/sign_up_spec.rb +258 -0
- data/spec/controllers/authentication_spec.rb +97 -0
- data/spec/controllers/localization_spec.rb +65 -0
- data/spec/controllers/request_can_carry_an_access_token_spec.rb +223 -0
- data/spec/fixtures/hello/password_mailer/confirmation +3 -0
- data/spec/fixtures/hello/password_mailer/forgot +3 -0
- data/spec/fixtures/hello/password_mailer/sign_up +3 -0
- data/spec/mailers/hello/mailer_spec.rb +53 -0
- data/spec/models/access_spec.rb +19 -0
- data/spec/models/credential_spec.rb +9 -0
- data/spec/models/email_credential_spec.rb +163 -0
- data/spec/models/hello/sign_up_model_spec.rb +64 -0
- data/spec/models/password_credential_spec.rb +75 -0
- data/spec/models/user_spec.rb +93 -0
- data/spec/others/configuration_spec.rb +25 -0
- data/spec/others/encryptors/complex_spec.rb +26 -0
- data/spec/others/encryptors/simple_spec.rb +21 -0
- data/spec/others/helper_spec.rb +10 -0
- data/spec/others/localization_consistency_spec.rb +73 -0
- data/spec/requests/forgot_password_spec.rb +36 -0
- data/spec/requests/reset_password_spec.rb +7 -0
- data/spec/requests/security/user_spec.rb +19 -0
- data/spec/routing/hello/accesses_routing_spec.rb +17 -0
- data/spec/routing/hello/emails_routing_spec.rb +37 -0
- data/spec/routing/hello/locale_routing_spec.rb +17 -0
- data/spec/routing/hello/profile_routing_spec.rb +29 -0
- data/spec/routing/hello/registration_routing_spec.rb +23 -0
- data/spec/routing/hello/sign_out_routing_spec.rb +11 -0
- data/spec/routing/hello/sudo_mode_routing_spec.rb +23 -0
- data/spec/routing/hello/users_routing_spec.rb +15 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/spec_helper/codeclimate.rb +2 -0
- data/spec/spec_helper/configure_rspec.rb +23 -0
- data/spec/spec_helper/create_database.rb +5 -0
- data/spec/spec_helper/dummy_and_test_dependencies.rb +17 -0
- data/spec/spec_helper/support.rb +1 -0
- data/spec/support/factories.rb +60 -0
- data/spec/support/feature_injection.rb +118 -0
- data/spec/support/features/feature_support_given.rb +46 -0
- data/spec/support/features/feature_support_then.rb +43 -0
- data/spec/support/helpers/aliases.rb +76 -0
- data/spec/support/helpers/configuration.rb +6 -0
- data/spec/support/helpers/current.rb +16 -0
- data/spec/support/helpers/expect.rb +61 -0
- data/spec/support/helpers/given.rb +49 -0
- data/spec/support/helpers/shortcuts.rb +24 -0
- data/spec/support/helpers/then.rb +29 -0
- data/spec/support/helpers/when.rb +108 -0
- data/spec/support/requests/request_support.rb +8 -0
- data/spec/utils/device_name_spec.rb +228 -0
- metadata +562 -11
@@ -0,0 +1,29 @@
|
|
1
|
+
<h1>Listing Users (<%= @count %>)</h1>
|
2
|
+
|
3
|
+
<% if current_user && current_user.webmaster? %>
|
4
|
+
<p><%= link_to "View User List as a Webmaster", list_users_path %></p>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<table class="table table-condensed">
|
8
|
+
<thead>
|
9
|
+
<tr>
|
10
|
+
<th>Username</th>
|
11
|
+
<th>Name</th>
|
12
|
+
<th>Role</th>
|
13
|
+
<th>Locale</th>
|
14
|
+
<th>Time zone</th>
|
15
|
+
</tr>
|
16
|
+
</thead>
|
17
|
+
|
18
|
+
<tbody>
|
19
|
+
<% @users.each do |user| %>
|
20
|
+
<tr>
|
21
|
+
<td><%= link_to user.username, user %></td>
|
22
|
+
<td><%= user.name %></td>
|
23
|
+
<td><%= user.role %></td>
|
24
|
+
<td><%= user.locale %></td>
|
25
|
+
<td><%= user.time_zone %></td>
|
26
|
+
</tr>
|
27
|
+
<% end %>
|
28
|
+
</tbody>
|
29
|
+
</table>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<h1>Listing Users (<%= @count %>)</h1>
|
2
|
+
|
3
|
+
<table class="table table-condensed">
|
4
|
+
<thead>
|
5
|
+
<tr>
|
6
|
+
<th>ID</th>
|
7
|
+
<th>Username</th>
|
8
|
+
<th>Name</th>
|
9
|
+
<th>Role</th>
|
10
|
+
<th>Locale</th>
|
11
|
+
<th>Time zone</th>
|
12
|
+
<th>Credentials</th>
|
13
|
+
<th>Accesses</th>
|
14
|
+
<!-- actions -->
|
15
|
+
<th colspan="1"></th>
|
16
|
+
</tr>
|
17
|
+
</thead>
|
18
|
+
|
19
|
+
<tbody>
|
20
|
+
<% @users.each do |user| %>
|
21
|
+
<tr>
|
22
|
+
<td>#<%= user.id %></td>
|
23
|
+
<td><%= link_to user.username, user %></td>
|
24
|
+
<td><%= user.name %></td>
|
25
|
+
<td><%= user.role %></td>
|
26
|
+
<td><%= user.locale %></td>
|
27
|
+
<td><%= user.time_zone %></td>
|
28
|
+
<td><%= user.credentials_count %></td>
|
29
|
+
<td><%= user.accesses_count %></td>
|
30
|
+
<!-- actions -->
|
31
|
+
<td><%= button_to "Impersonate!", impersonate_user_path(user) if current_user != user %></td>
|
32
|
+
</tr>
|
33
|
+
<% end %>
|
34
|
+
</tbody>
|
35
|
+
</table>
|
@@ -0,0 +1,60 @@
|
|
1
|
+
<%= form_for @user, as: :user, url: users_path, html: {class: "form-horizontal", role: "form"} do |f| %>
|
2
|
+
|
3
|
+
<!-- Errors -->
|
4
|
+
<% if @user.errors.any? %>
|
5
|
+
<%= render '/hello/shared/errors', business: @user %>
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
<div class="form-group">
|
9
|
+
<%= label_tag :role, nil, class: "col-sm-4 control-label" %>
|
10
|
+
<div class="col-sm-4">
|
11
|
+
<%= text_field_tag :role, @starting_role, class: "form-control", placeholder: "Role" %>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<div class="form-group">
|
16
|
+
<%= f.label :name, class: "col-sm-4 control-label" %>
|
17
|
+
<div class="col-sm-4">
|
18
|
+
<%= f.text_field :name, class: "form-control", placeholder: "Name" %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<div class="form-group">
|
23
|
+
<%= f.label :email, class: "col-sm-4 control-label" %>
|
24
|
+
<div class="col-sm-4">
|
25
|
+
<%= f.text_field :email, class: "form-control", placeholder: "Email" %>
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
<div class="form-group">
|
29
|
+
<%= f.label :username, class: "col-sm-4 control-label" %>
|
30
|
+
<div class="col-sm-4">
|
31
|
+
<%= f.text_field :username, class: "form-control", placeholder: "Username" %>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
<div class="form-group">
|
35
|
+
<%= f.label :password, class: "col-sm-4 control-label" %>
|
36
|
+
<div class="col-sm-4">
|
37
|
+
<%= f.password_field :password, class: "form-control", placeholder: "Password" %>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div class="form-group">
|
42
|
+
<%= f.label :locale, class: "col-sm-4 control-label" %>
|
43
|
+
<div class="col-sm-4">
|
44
|
+
<%= f.select :locale, hello_locale_select_options, {}, class: "form-control" %>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<div class="form-group">
|
49
|
+
<%= f.label :time_zone, class: "col-sm-4 control-label" %>
|
50
|
+
<div class="col-sm-4">
|
51
|
+
<%= f.time_zone_select :time_zone, nil, {}, class: "form-control" %>
|
52
|
+
</div>
|
53
|
+
</div>
|
54
|
+
|
55
|
+
<div class="form-group">
|
56
|
+
<div class="col-sm-offset-4 col-sm-4">
|
57
|
+
<%= f.submit "Create User", class: "btn btn-primary" %>
|
58
|
+
</div>
|
59
|
+
</div>
|
60
|
+
<% end %>
|
@@ -0,0 +1,74 @@
|
|
1
|
+
<div class="panel panel-info">
|
2
|
+
<div class="panel-heading">
|
3
|
+
<h3 class="panel-title"><%= @user.name %></h3>
|
4
|
+
</div>
|
5
|
+
<div class="panel-body">
|
6
|
+
<div class="row">
|
7
|
+
<div class="col-md-3 col-lg-3 " align="center">
|
8
|
+
<img alt="User Pic" src="http://placehold.it/300x300" class="img-circle img-responsive">
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class=" col-md-9 col-lg-9 ">
|
12
|
+
<table class="table table-user-information">
|
13
|
+
<tbody>
|
14
|
+
<tr>
|
15
|
+
<td>ID:</td>
|
16
|
+
<td>#<%= @user.id %></td>
|
17
|
+
</tr>
|
18
|
+
<tr>
|
19
|
+
<td>Username:</td>
|
20
|
+
<td><%= @user.username %></td>
|
21
|
+
</tr>
|
22
|
+
<tr>
|
23
|
+
<td>Page:</td>
|
24
|
+
<td><%= user_url(@user) %></td>
|
25
|
+
</tr>
|
26
|
+
<tr>
|
27
|
+
<td>Role</td>
|
28
|
+
<td><%= @user.role %></td>
|
29
|
+
</tr>
|
30
|
+
<tr>
|
31
|
+
<td>Locale</td>
|
32
|
+
<td><%= @user.locale %></td>
|
33
|
+
</tr>
|
34
|
+
<tr>
|
35
|
+
<td>Time zone</td>
|
36
|
+
<td><%= @user.time_zone %></td>
|
37
|
+
</tr>
|
38
|
+
<tr>
|
39
|
+
<td>Email:</td>
|
40
|
+
<td><%= @user.email_credentials.map(&:email).to_sentence %></td>
|
41
|
+
</tr>
|
42
|
+
<tr>
|
43
|
+
<td>Credentials:</td>
|
44
|
+
<td><%= @user.credentials_count %></td>
|
45
|
+
</tr>
|
46
|
+
<tr>
|
47
|
+
<td>Accesses:</td>
|
48
|
+
<td><%= @user.accesses_count %></td>
|
49
|
+
</tr>
|
50
|
+
<tr>
|
51
|
+
<td>Created:</td>
|
52
|
+
<td><%= l @user.created_at, format: :long %></td>
|
53
|
+
</tr>
|
54
|
+
<tr>
|
55
|
+
<td>Updated</td>
|
56
|
+
<td><%= l @user.updated_at, format: :long %></td>
|
57
|
+
</tr>
|
58
|
+
|
59
|
+
</tbody>
|
60
|
+
</table>
|
61
|
+
|
62
|
+
<a href="#" class="btn btn-primary">Button</a>
|
63
|
+
<a href="#" class="btn btn-primary">Button</a>
|
64
|
+
</div>
|
65
|
+
</div>
|
66
|
+
</div>
|
67
|
+
<div class="panel-footer">
|
68
|
+
<a data-original-title="Broadcast Message" data-toggle="tooltip" type="button" class="btn btn-sm btn-primary"><i class="glyphicon glyphicon-envelope"></i></a>
|
69
|
+
<span class="pull-right">
|
70
|
+
<a data-original-title="Broadcast Message" data-toggle="tooltip" type="button" class="btn btn-sm btn-primary"><i class="glyphicon glyphicon-envelope"></i></a>
|
71
|
+
<a data-original-title="Broadcast Message" data-toggle="tooltip" type="button" class="btn btn-sm btn-primary"><i class="glyphicon glyphicon-envelope"></i></a>
|
72
|
+
</span>
|
73
|
+
</div>
|
74
|
+
</div>
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'hello'
|
2
|
+
|
3
|
+
class Hello::LocalesGenerator < Rails::Generators::Base
|
4
|
+
source_root Hello.root
|
5
|
+
|
6
|
+
argument :selected_locales, type: :array, default: [], banner: 'lang1 [lang2] [lang3]'
|
7
|
+
|
8
|
+
def copy_locales
|
9
|
+
case
|
10
|
+
when selected_locales == []
|
11
|
+
puts_usage
|
12
|
+
puts
|
13
|
+
when selected_locales == ['all']
|
14
|
+
copy_them(available_locales)
|
15
|
+
when missing_locales.any?
|
16
|
+
puts_usage
|
17
|
+
puts_matching
|
18
|
+
puts_missing
|
19
|
+
puts
|
20
|
+
else
|
21
|
+
copy_them(matching_locales)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
protected
|
27
|
+
|
28
|
+
def copy_them(locales)
|
29
|
+
locales.sort.each do |l|
|
30
|
+
copy_file "config/locales/hello.#{l}.yml"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def puts_usage
|
35
|
+
puts
|
36
|
+
puts "Usage:".light_yellow
|
37
|
+
puts " rails generate hello:locales all"
|
38
|
+
puts " rails generate hello:locales #{available_locales.sort.join(' ')}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def puts_missing
|
42
|
+
puts
|
43
|
+
puts "Missing:".light_red
|
44
|
+
puts " rails generate hello:locales #{missing_locales.sort.join(' ')}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def puts_matching
|
48
|
+
puts
|
49
|
+
puts "Matching:".light_green
|
50
|
+
puts " rails generate hello:locales #{matching_locales.sort.join(' ')}"
|
51
|
+
end
|
52
|
+
|
53
|
+
def matching_locales
|
54
|
+
selected_locales & available_locales
|
55
|
+
end
|
56
|
+
|
57
|
+
def missing_locales
|
58
|
+
selected_locales - available_locales
|
59
|
+
end
|
60
|
+
|
61
|
+
def available_locales
|
62
|
+
Dir[Hello.root.join('config', 'locales', '**', '*.yml')].map { |s| s.split('.')[-2] }
|
63
|
+
end
|
64
|
+
end
|
data/lib/hello-rails.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'hello'
|
data/lib/hello.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
|
3
|
+
require_relative 'hello/engine'
|
4
|
+
require_relative 'hello/configuration'
|
5
|
+
|
6
|
+
module Hello
|
7
|
+
def self.root
|
8
|
+
@root ||= Pathname(File.dirname(__FILE__)).join('..')
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.warning(s2)
|
12
|
+
s1 = 'HELLO DEV WARNING:'.black.on_yellow.bold
|
13
|
+
puts "#{s1} #{s2.yellow}"
|
14
|
+
end
|
15
|
+
|
16
|
+
autoload :Business, 'hello/business'
|
17
|
+
autoload :TimeZones, 'hello/time_zones'
|
18
|
+
autoload :Encryptors, 'hello/encryptors'
|
19
|
+
autoload :RailsActiveRecord, 'hello/rails_active_record'
|
20
|
+
autoload :RailsController, 'hello/rails_controller'
|
21
|
+
autoload :RailsHelper, 'hello/rails_helper'
|
22
|
+
autoload :Errors, 'hello/errors'
|
23
|
+
autoload :Utils, 'hello/utils'
|
24
|
+
autoload :Middleware, 'hello/middleware'
|
25
|
+
autoload :Locales, 'hello/locales'
|
26
|
+
autoload :RequestManager, 'hello/request_manager'
|
27
|
+
end
|
28
|
+
|
29
|
+
if defined? Rails
|
30
|
+
require 'before_actions'
|
31
|
+
require 'http_accept_language'
|
32
|
+
require 'rails-i18n'
|
33
|
+
|
34
|
+
ActionView::Base.include Hello::RailsHelper
|
35
|
+
ActionController::Base.include Hello::RailsController
|
36
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
v 0.1.2 In Progress
|
2
|
+
-----------
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
v 0.1.1
|
7
|
+
-----------
|
8
|
+
|
9
|
+
- Admin Impersonation
|
10
|
+
- Forgot Password and Welcome mailers
|
11
|
+
- Confirm Email
|
12
|
+
- I18n
|
13
|
+
- JSON responses for sign_up, sign_in and sign_out
|
14
|
+
- Reviewed configuration pattern
|
15
|
+
|
16
|
+
v 0.1.0
|
17
|
+
-----------
|
18
|
+
|
19
|
+
- BCrypt as suggested cryptography strategy
|
20
|
+
- generator "hello:from_devise"
|
21
|
+
- generator "hello:views"
|
22
|
+
- multiple devices
|
23
|
+
- sudo mode
|
24
|
+
- configurable classic forgot password
|
25
|
+
- configurable classic sign in
|
26
|
+
- configurable classic sign up
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Hello
|
2
|
+
module Business
|
3
|
+
extend ActiveSupport::Autoload
|
4
|
+
|
5
|
+
# Business are used to encapsulate behaviors and translations
|
6
|
+
|
7
|
+
# please keep alphabetical order
|
8
|
+
|
9
|
+
autoload :Base
|
10
|
+
|
11
|
+
module Authentication
|
12
|
+
extend ActiveSupport::Autoload
|
13
|
+
|
14
|
+
autoload :SignIn
|
15
|
+
autoload :SignOut
|
16
|
+
autoload :SudoModeAuthentication
|
17
|
+
autoload :SudoModeExpiration
|
18
|
+
end
|
19
|
+
|
20
|
+
module Internationalization
|
21
|
+
extend ActiveSupport::Autoload
|
22
|
+
|
23
|
+
autoload :UpdateLocale
|
24
|
+
end
|
25
|
+
|
26
|
+
module Management
|
27
|
+
extend ActiveSupport::Autoload
|
28
|
+
|
29
|
+
autoload :AddEmail
|
30
|
+
autoload :CancelAccount
|
31
|
+
autoload :ConfirmEmail
|
32
|
+
autoload :ForgotPassword
|
33
|
+
autoload :RemoveEmail
|
34
|
+
autoload :ResetPassword
|
35
|
+
autoload :SendConfirmationEmail
|
36
|
+
autoload :UnlinkAccess
|
37
|
+
autoload :UpdateProfile
|
38
|
+
end
|
39
|
+
|
40
|
+
module Registration
|
41
|
+
extend ActiveSupport::Autoload
|
42
|
+
|
43
|
+
autoload :SignUp
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module Hello
|
2
|
+
module Business
|
3
|
+
module Authentication
|
4
|
+
class SignIn < Base
|
5
|
+
attr_accessor :login, :password
|
6
|
+
|
7
|
+
def authenticate(login, password)
|
8
|
+
@ignited = true
|
9
|
+
@login = login
|
10
|
+
@password = password
|
11
|
+
|
12
|
+
validates_presence_of :login, :password
|
13
|
+
return false if any_errors?
|
14
|
+
|
15
|
+
find_user_by_login
|
16
|
+
check_login_found
|
17
|
+
return false if any_errors?
|
18
|
+
|
19
|
+
check_password_matches
|
20
|
+
return false if any_errors?
|
21
|
+
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
def bad_login?
|
26
|
+
!!@bad_login
|
27
|
+
end
|
28
|
+
|
29
|
+
def bad_password?
|
30
|
+
!!@bad_password
|
31
|
+
end
|
32
|
+
|
33
|
+
def user
|
34
|
+
@user ||= ::User.new
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
# authenticate helpers
|
40
|
+
|
41
|
+
def any_errors?
|
42
|
+
errors.full_messages.any?
|
43
|
+
end
|
44
|
+
|
45
|
+
def find_user_by_login
|
46
|
+
@user = if login_is_email?
|
47
|
+
find_user_by_login_email
|
48
|
+
else
|
49
|
+
find_user_by_login_username
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def find_user_by_login_email
|
54
|
+
e = ::EmailCredential.find_by_email(login)
|
55
|
+
e && e.user
|
56
|
+
end
|
57
|
+
|
58
|
+
def find_user_by_login_username
|
59
|
+
::User.where(username: login).first
|
60
|
+
end
|
61
|
+
|
62
|
+
def check_login_found
|
63
|
+
add_errors_for_login_not_found if @user.nil?
|
64
|
+
end
|
65
|
+
|
66
|
+
def check_password_matches
|
67
|
+
add_errors_for_password_incorrect unless user.password_is?(password)
|
68
|
+
end
|
69
|
+
|
70
|
+
def add_errors_for_login_not_found
|
71
|
+
@bad_login = true
|
72
|
+
errors.add(:login, 'was not found')
|
73
|
+
end
|
74
|
+
|
75
|
+
def add_errors_for_password_incorrect
|
76
|
+
@bad_password = true
|
77
|
+
errors.add(:password, 'is incorrect')
|
78
|
+
end
|
79
|
+
|
80
|
+
# helpers
|
81
|
+
|
82
|
+
def login_is_email?
|
83
|
+
login.to_s.include? '@'
|
84
|
+
end
|
85
|
+
|
86
|
+
def ignited
|
87
|
+
@ignited || false
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|