usman 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +38 -0
  4. data/Rakefile +37 -0
  5. data/app/assets/config/usman_manifest.js +2 -0
  6. data/app/assets/javascripts/usman/application.js +13 -0
  7. data/app/assets/stylesheets/usman/application.css +15 -0
  8. data/app/controllers/usman/admin/base_controller.rb +24 -0
  9. data/app/controllers/usman/admin/dashboard_controller.rb +18 -0
  10. data/app/controllers/usman/admin/features_controller.rb +86 -0
  11. data/app/controllers/usman/admin/permissions_controller.rb +76 -0
  12. data/app/controllers/usman/admin/resource_controller.rb +11 -0
  13. data/app/controllers/usman/admin/users_controller.rb +117 -0
  14. data/app/controllers/usman/application_controller.rb +13 -0
  15. data/app/controllers/usman/sessions_controller.rb +84 -0
  16. data/app/helpers/usman/application_helper.rb +4 -0
  17. data/app/helpers/usman/authentication_helper.rb +120 -0
  18. data/app/jobs/usman/application_job.rb +4 -0
  19. data/app/mailers/usman/application_mailer.rb +6 -0
  20. data/app/models/feature.rb +112 -0
  21. data/app/models/image/base.rb +30 -0
  22. data/app/models/image/feature_image.rb +3 -0
  23. data/app/models/image/profile_picture.rb +3 -0
  24. data/app/models/permission.rb +28 -0
  25. data/app/models/user.rb +247 -0
  26. data/app/models/usman/application_record.rb +5 -0
  27. data/app/services/usman/authentication_service.rb +45 -0
  28. data/app/uploaders/feature_image_uploader.rb +14 -0
  29. data/app/uploaders/image_uploader.rb +90 -0
  30. data/app/uploaders/profile_picture_uploader.rb +14 -0
  31. data/app/views/layouts/kuppayam/_footer.html.erb +25 -0
  32. data/app/views/layouts/kuppayam/_header.html.erb +43 -0
  33. data/app/views/layouts/kuppayam/_navbar.html.erb +55 -0
  34. data/app/views/layouts/kuppayam/_sidebar.html.erb +78 -0
  35. data/app/views/usman/admin/dashboard/index.html.erb +52 -0
  36. data/app/views/usman/admin/features/_action_buttons.html.erb +11 -0
  37. data/app/views/usman/admin/features/_form.html.erb +19 -0
  38. data/app/views/usman/admin/features/_index.html.erb +79 -0
  39. data/app/views/usman/admin/features/_row.html.erb +55 -0
  40. data/app/views/usman/admin/features/_show.html.erb +48 -0
  41. data/app/views/usman/admin/features/create.js.erb +16 -0
  42. data/app/views/usman/admin/features/destroy.js.erb +16 -0
  43. data/app/views/usman/admin/features/edit.js.erb +7 -0
  44. data/app/views/usman/admin/features/index.html.erb +25 -0
  45. data/app/views/usman/admin/features/index.js.erb +8 -0
  46. data/app/views/usman/admin/features/new.js.erb +7 -0
  47. data/app/views/usman/admin/features/row.js.erb +10 -0
  48. data/app/views/usman/admin/features/show.js.erb +8 -0
  49. data/app/views/usman/admin/features/update.js.erb +16 -0
  50. data/app/views/usman/admin/permissions/_action_buttons.html.erb +11 -0
  51. data/app/views/usman/admin/permissions/_form.html.erb +70 -0
  52. data/app/views/usman/admin/permissions/_index.html.erb +56 -0
  53. data/app/views/usman/admin/permissions/_row.html.erb +27 -0
  54. data/app/views/usman/admin/permissions/_show.html.erb +48 -0
  55. data/app/views/usman/admin/permissions/create.js.erb +17 -0
  56. data/app/views/usman/admin/permissions/destroy.js.erb +16 -0
  57. data/app/views/usman/admin/permissions/edit.js.erb +7 -0
  58. data/app/views/usman/admin/permissions/index.html.erb +25 -0
  59. data/app/views/usman/admin/permissions/index.js.erb +8 -0
  60. data/app/views/usman/admin/permissions/new.js.erb +7 -0
  61. data/app/views/usman/admin/permissions/row.js.erb +10 -0
  62. data/app/views/usman/admin/permissions/show.js.erb +8 -0
  63. data/app/views/usman/admin/permissions/update.js.erb +16 -0
  64. data/app/views/usman/admin/users/_action_buttons.html.erb +11 -0
  65. data/app/views/usman/admin/users/_form.html.erb +36 -0
  66. data/app/views/usman/admin/users/_index.html.erb +120 -0
  67. data/app/views/usman/admin/users/_row.html.erb +92 -0
  68. data/app/views/usman/admin/users/_show.html.erb +132 -0
  69. data/app/views/usman/admin/users/create.js.erb +16 -0
  70. data/app/views/usman/admin/users/destroy.js.erb +16 -0
  71. data/app/views/usman/admin/users/edit.js.erb +7 -0
  72. data/app/views/usman/admin/users/index.html.erb +40 -0
  73. data/app/views/usman/admin/users/index.js.erb +8 -0
  74. data/app/views/usman/admin/users/new.js.erb +7 -0
  75. data/app/views/usman/admin/users/row.js.erb +10 -0
  76. data/app/views/usman/admin/users/show.js.erb +8 -0
  77. data/app/views/usman/admin/users/update.js.erb +16 -0
  78. data/app/views/usman/sessions/_form.html.erb +48 -0
  79. data/app/views/usman/sessions/_sign_in.js.erb +3 -0
  80. data/app/views/usman/sessions/sign_in.html.erb +63 -0
  81. data/config/locales/usman.en.yml +61 -0
  82. data/config/routes.rb +45 -0
  83. data/db/migrate/20131108102728_create_images.rb +12 -0
  84. data/db/migrate/20140402113213_create_users.rb +57 -0
  85. data/db/migrate/20140402113214_create_features.rb +24 -0
  86. data/lib/tasks/usman_tasks.rake +4 -0
  87. data/lib/usman/engine.rb +14 -0
  88. data/lib/usman/version.rb +3 -0
  89. data/lib/usman.rb +5 -0
  90. metadata +418 -0
@@ -0,0 +1,92 @@
1
+ <% edit_link = edit_admin_user_path(id: user.id) %>
2
+ <% delete_link = admin_user_path(id: user.id) %>
3
+
4
+ <tr id="tr_user_<%= user.id %>">
5
+
6
+ <!-- <td class="user-cb">
7
+ <input type="checkbox" class="cbr" name="users[]" value="1" checked />
8
+ </td> -->
9
+
10
+ <!-- <th scope="row" style="text-align: center;">
11
+ <%# if i < 0 %>
12
+ <i class="fa fa-check text-success"></i>
13
+ <%# else %>
14
+ <%#= i + 1 + (@per_page.to_i * (@current_page.to_i - 1)) %>
15
+ <%# end %>
16
+ </th> -->
17
+
18
+ <td class="user-image hidden-xs hidden-sm">
19
+ <a href="#">
20
+ <%= display_image(user, "profile_picture.image.small.url", width: "32", height: "auto", class: "img-circle", alt: user.display_name) %>
21
+ </a>
22
+ </td>
23
+
24
+ <td class="user-name"><%= link_to user.name, admin_user_path(user), remote: true %></td>
25
+
26
+ <td class="hidden-xs hidden-sm"><%= link_to user.username, "#" %></td>
27
+
28
+ <td class="hidden-xs hidden-sm"><%= link_to user.email, "#", class: "email" %></td>
29
+
30
+ <% if @current_user.is_super_admin? %>
31
+ <td class="hidden-xs hidden-sm">
32
+ <% if user.super_admin %>
33
+ <span class="mr-10 mt-5 label label-warning">Super Admin</span>
34
+ <% else %>
35
+ <span class="mr-10 mt-5 label label-default">Normal</span>
36
+ <% end %>
37
+ </td>
38
+ <% end %>
39
+
40
+ <td>
41
+ <% if user.pending? %>
42
+ <span class="ml-5 mt-5 label label-default">Pending</span>
43
+ <% elsif user.approved? %>
44
+ <span class="ml-5 mt-5 label label-success">Approved</span>
45
+ <% elsif user.suspended? %>
46
+ <span class="ml-5 mt-5 label label-danger">Suspended</span>
47
+ <% end %>
48
+ </td>
49
+
50
+ <td class="action-links" style="width:15%">
51
+
52
+ <%= link_to raw("<i class=\"linecons-pencil\"></i> Edit User"), edit_link, :remote=>true, class: "edit" %>
53
+
54
+ <%= link_to raw("<i class=\"linecons-trash\"></i> Delete"), delete_link, method: :delete, role: "menuitem", tabindex: "-1", data: { confirm: 'Are you sure?' }, :remote=>true, class: "delete" if @current_user != user %>
55
+
56
+ <% if @current_user.super_admin? %>
57
+ <%= link_to raw("<i class=\"linecons-paper-plane\"></i> Masquerade"), masquerade_admin_user_path(user), method: :put, data: { confirm: "Are you sure? Do you really want to logout current session and login as #{user.name}?" } %>
58
+ <% end %>
59
+
60
+ </td>
61
+
62
+ <td class="action-links" style="width:15%">
63
+
64
+ <% if @current_user.super_admin? %>
65
+ <% if user.super_admin? %>
66
+ <!-- Remove Super Admin -->
67
+ <%= link_to raw("<i class=\"fa fa-remove mr-5\"></i> Remove Super Admin"), remove_super_admin_admin_user_path(id: user.id), method: :put, :remote=>true, role: "menuitem", tabindex: "-1" %>
68
+ <% else %>
69
+ <!-- Make Super Admin -->
70
+ <%= link_to raw("<i class=\"fa fa-plus-square mr-5\"></i> Make Super Admin"), make_super_admin_admin_user_path(id: user.id), method: :put, remote: true, role: "menuitem", tabindex: "-1" %>
71
+ <% end %>
72
+ <% end %>
73
+
74
+ <% case user.status %>
75
+ <% when "approved" %>
76
+ <!-- Pending -->
77
+ <%= link_to raw("<i class=\"fa fa-circle mr-5\"></i> Mark as Pending"), update_status_admin_user_path(:id =>user.id, :status =>'pending'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"user_status" %>
78
+
79
+ <!-- Suspend -->
80
+ <%= link_to raw("<i class=\"fa fa-edit mr-5\"></i> Suspend"), update_status_admin_user_path(:id =>user.id, :status =>'suspended'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"user_status" %>
81
+ <% when "pending" %>
82
+ <!-- Approve -->
83
+ <%= link_to raw("<i class=\"fa fa-circle-o mr-5\"></i> Approve"), update_status_admin_user_path(:id =>user.id, :status =>'approved'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"user_status" %>
84
+ <% when "suspended" %>
85
+ <!-- Approve -->
86
+ <%= link_to raw("<i class=\"fa fa-circle-o mr-5\"></i> Approve"), update_status_admin_user_path(:id =>user.id, :status =>'approved'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1",:class=>"user_status" %>
87
+ <% end %>
88
+
89
+ </td>
90
+
91
+ </tr>
92
+
@@ -0,0 +1,132 @@
1
+ <% status_hash = {approved: "success", pending: "default", removed: "danger"} %>
2
+
3
+ <div class="media p-5 <%= status_hash[@user.status.to_sym] %>">
4
+
5
+ <div class="pull-left p-40" style="width:30%;">
6
+ <%= edit_image(@user, "profile_picture.image.large.url", upload_image_link(@user, :profile_picture)) %>
7
+ </div>
8
+
9
+ <div class="pull-left ml-10" style="width:65%;">
10
+
11
+ <h1><%= @user.name %></h1>
12
+
13
+ <span class="ml-5 mt-5 label label-<%= status_hash[@user.status.to_sym] %>"><%= @user.status.titleize %></span>
14
+
15
+ <% if @user.super_admin %>
16
+ <span class="mr-10 mt-5 label label-warning">Super Admin</span>
17
+ <% else %>
18
+ <span class="mr-10 mt-5 label label-default">Normal</span>
19
+ <% end %>
20
+
21
+ <%= clear_tag %>
22
+
23
+ <div class="table-responsive mt-30">
24
+ <table class="table table-striped table-condensed table-bordered">
25
+ <tbody>
26
+
27
+ <tr>
28
+ <th>Username</th><td><%= @user.username %></td>
29
+ <th>Email</th><td><%= @user.email %></td>
30
+ </tr>
31
+
32
+ <tr>
33
+ <th>Phone</th><td><%= @user.phone %></td>
34
+ <th>Designation</th><td><%= @user.designation %></td>
35
+ </tr>
36
+
37
+ <tr>
38
+ <th>Super Admim?</th><td><%= @user.super_admin %></td>
39
+ <th>Status</th><td><%= @user.status.titleize %></td>
40
+ </tr>
41
+
42
+ </tbody>
43
+ </table>
44
+ </div>
45
+
46
+ <%= clear_tag %>
47
+ </div>
48
+
49
+ </div>
50
+
51
+ <h4 class="mb-20">Technical Details</h4>
52
+
53
+ <div class="table-responsive">
54
+ <table class="table table-striped table-condensed table-bordered mb-30">
55
+ <tbody>
56
+
57
+
58
+ <tr>
59
+ <th style="width:20%;">Sign In Count</th><td style="width:30%;"><%= @user.sign_in_count %></td>
60
+ <th style="width:20%;">Remember User</th><td style="width:30%;"><%= @user.remember_created_at.strftime("%m/%d/%Y - %H:%M:%S") if @user.remember_created_at %></td>
61
+ </tr>
62
+
63
+ <tr>
64
+ <th>Current Sign In At</th><td><%= @user.current_sign_in_at.strftime("%m/%d/%Y - %H:%M:%S") if @user.current_sign_in_at %></td>
65
+ <th>Last Sign In At</th><td><%= @user.last_sign_in_at.strftime("%m/%d/%Y - %H:%M:%S") if @user.last_sign_in_at %></td>
66
+ </tr>
67
+
68
+ <tr>
69
+ <th>Current Sign In IP</th><td><%= @user.current_sign_in_ip %></td>
70
+ <th>Last Sign In IP</th><td><%= @user.last_sign_in_ip %></td>
71
+ </tr>
72
+
73
+ </tbody>
74
+ </table>
75
+ </div>
76
+
77
+ <div class="table-responsive">
78
+ <table class="table table-striped table-condensed table-bordered">
79
+ <tbody>
80
+
81
+ <tr>
82
+ <th style="width:20%;">Reset Password Token</th><td style="width:30%;"><%= @user.reset_password_token %></td>
83
+ <th style="width:20%;">Reset Password Sent At</th><td style="width:30%;"><%= @user.reset_password_sent_at.strftime("%m/%d/%Y - %H:%M:%S") if @user.reset_password_sent_at %></td>
84
+ </tr>
85
+
86
+ <tr>
87
+ <th>Locked At</th><td colspan="3"><%= @user.locked_at.strftime("%m/%d/%Y - %H:%M:%S") if @user.locked_at %></td>
88
+ </tr>
89
+
90
+ <tr>
91
+ <th>Failed Attempts</th><td><%= @user.failed_attempts %></td>
92
+ <th>Unlock Token</th><td><%= @user.unlock_token %></td>
93
+ </tr>
94
+
95
+ <tr>
96
+ <th>Confirmation Token</th><td><%= @user.confirmation_token %></td>
97
+ <th>Confirmation Token Sent At</th><td><%= @user.confirmed_at.strftime("%m/%d/%Y - %H:%M:%S") if @user.confirmed_at %></td>
98
+ </tr>
99
+
100
+ <tr>
101
+ <th>Confirmation Sent At</th><td><%= @user.confirmation_sent_at.strftime("%m/%d/%Y - %H:%M:%S") if @user.confirmation_sent_at %></td>
102
+ <th>Uncomfirmed Email</th><td><%= @user.unconfirmed_email %></td>
103
+ </tr>
104
+
105
+ <tr>
106
+ <th>Auth Token</th><td><%= @user.auth_token %></td>
107
+ <th>Token Created At</th><td><%= @user.token_created_at.strftime("%m/%d/%Y - %H:%M:%S") if @user.token_created_at %></td>
108
+ </tr>
109
+
110
+ <tr>
111
+ <th>Created At</th><td><%= @user.created_at.strftime("%m/%d/%Y - %H:%M:%S") if @user.created_at %></td>
112
+ <th>Updated At</th><td><%= @user.updated_at.strftime("%m/%d/%Y - %H:%M:%S") if @user.updated_at %></td>
113
+ </tr>
114
+
115
+ </tbody>
116
+ </table>
117
+ </div>
118
+
119
+ <div>
120
+ <%
121
+ edit_link = edit_admin_user_url(id: @user.id)
122
+ delete_link = admin_user_url(id: @user.id)
123
+ %>
124
+
125
+ <%= link_to raw("<i class=\"fa fa-close mr-5\"></i> <span>Cancel</span>"), "#", onclick: "closeLargeModal();", class: "btn btn-white pull-left" %>
126
+
127
+ <%= link_to raw("<i class=\"fa fa-trash mr-5\"></i> <span>Delete User</span>"), delete_link, method: :delete, :remote=>true, class: "btn btn-gray pull-right" %>
128
+
129
+ <%= link_to raw("<i class=\"fa fa-edit mr-5\"></i> Edit User"), edit_link, method: :get, :remote=>true, class: "btn btn-gray pull-right mr-10" %>
130
+ </div>
131
+
132
+ <%= clear_tag %>
@@ -0,0 +1,16 @@
1
+ <% if @user.errors.blank? %>
2
+ closeLargeModal();
3
+ $('#div_user_index table > tbody > tr:first').before("<%= escape_javascript(render(:partial=>'/usman/admin/users/row', locals: {user: @user})) %>")
4
+ $("#tr_user_<%= @user.id %>").css("background-color", "#fffddd");
5
+ <% else %>
6
+ // Show the form in the modal
7
+ heading = "Add a User";
8
+ bodyContent = "<%= escape_javascript(render(:partial=>'/usman/admin/users/form')) %>";
9
+ showLargeModal(heading, bodyContent);
10
+ var $div = $('<iframe id="iframe_user" name="iframe_user" width="100%" style="display:none"></iframe>').appendTo('body');
11
+ <%
12
+ text = "You have few errors. They have been highlighted."
13
+ error_message = content_tag(:div, text, class: "alert alert-danger")
14
+ %>
15
+ $("#user_form_error").html("<%= escape_javascript(error_message) %>");
16
+ <% end %>
@@ -0,0 +1,16 @@
1
+ <% if @destroyed %>
2
+ closeLargeModal();
3
+ $('#div_user_index').html("<%= escape_javascript(render(:partial=>'/usman/admin/users/index')) %>");
4
+ <% else %>
5
+ // Show the error in a modal
6
+ <%
7
+ text = User::DELETE_MESSAGE
8
+ error_message = content_tag(:div, text, class: 'alert alert-danger')
9
+ %>
10
+ heading = "Remove '<%= @user.name %>'";
11
+ bodyContent = "<%= escape_javascript(error_message) %>";
12
+ showLargeModal(heading, bodyContent);
13
+ var $div = $('<iframe id="iframe_user" name="iframe_user" width="100%" style="display:none"></iframe>').appendTo('body');
14
+ <% end %>
15
+
16
+
@@ -0,0 +1,7 @@
1
+ // Show the new form in the right box.
2
+ heading = "Edit '<%= raw @user.name_was %>'";
3
+ bodyContent = "<%= escape_javascript(render(:partial=>'/usman/admin/users/form')) %>";
4
+ showLargeModal(heading, bodyContent);
5
+
6
+ // When the image upload form is submitted, the server response will appear in this iframe -->
7
+ var $div = $('<iframe id="iframe_user" name="iframe_user" width="100%" style="display:none"></iframe>').appendTo('body');
@@ -0,0 +1,40 @@
1
+ <div class="row">
2
+
3
+ <div class="col-md-12">
4
+ <ul class="nav nav-tabs">
5
+
6
+ <%# Show Admin tab only for admins %>
7
+ <% if @current_user.is_super_admin? %>
8
+ <li class="<%= @super_admin == false ? 'active' : '' %>">
9
+ <%= link_to "Users", admin_users_path(sa: '0') %>
10
+ </li>
11
+ <li class="<%= @super_admin == true ? 'active' : '' %>">
12
+ <%= link_to "Administrators", admin_users_path(sa: '1') %>
13
+ </li>
14
+ <% else %>
15
+ <li class="active">
16
+ <%= link_to "Users", admin_users_path(sa: '0') %>
17
+ </li>
18
+ <% end %>
19
+
20
+ </ul>
21
+
22
+ <div class="tab-content">
23
+ <div class="tab-pane active">
24
+
25
+ <div id="div_user_action_buttons">
26
+ <%= render :partial=>"usman/admin/users/action_buttons" %>
27
+ </div>
28
+ <%= clear_tag(10) %>
29
+
30
+ <div id="div_user_index">
31
+ <%= render :partial=>"usman/admin/users/index" %>
32
+ </div>
33
+ <%= clear_tag(10) %>
34
+
35
+ </div>
36
+ </div>
37
+
38
+ </div>
39
+
40
+ </div>
@@ -0,0 +1,8 @@
1
+ closeLargeModal();
2
+ <% if @users.any? %>
3
+ // Fill the right box with first enquiry details in the list
4
+ $('#div_user_index').html("<%= escape_javascript(render(:partial=>'/usman/admin/users/index')) %>");
5
+ <% else %>
6
+ var noResultsText = "<%= escape_javascript(theme_panel_message(I18n.translate('forms.no_results')))%>";
7
+ $('#div_user_index').html(noResultsText);
8
+ <% end %>
@@ -0,0 +1,7 @@
1
+ // Show the new form in the right box.
2
+ heading = "Add a User";
3
+ bodyContent = "<%= escape_javascript(render(:partial=>'/usman/admin/users/form')) %>";
4
+ showLargeModal(heading, bodyContent);
5
+
6
+ // When the image upload form is submitted, the server response will appear in this iframe -->
7
+ var $div = $('<iframe id="iframe_user" name="iframe_user" width="100%" style="display:none"></iframe>').appendTo('body');
@@ -0,0 +1,10 @@
1
+ <% if @user.errors.blank? %>
2
+ <% status_hash = {approved: "success", pending: "default", suspeneded: "danger"} %>
3
+ $("#tr_user_<%= @user.id %>").replaceWith("<%= escape_javascript(render(:partial=>'/usman/admin/users/row', locals: {user: @user, i: -1})) %>")
4
+ // Close Modal
5
+ closeLargeModal();
6
+ <% else %>
7
+ // Populate Server Side Errors
8
+ errorMessages = <%= @user.errors.full_messages.to_json.html_safe %>;
9
+ populateServerSideErrors('user', errorMessages);
10
+ <% end %>
@@ -0,0 +1,8 @@
1
+ // Show the new form in the right box.
2
+ heading = "<%= raw @user.name %>";
3
+ bodyContent = "<%= escape_javascript(render(:partial=>'/usman/admin/users/show')) %>";
4
+ closeLargeModal();
5
+ showLargeModal(heading, bodyContent);
6
+
7
+ // When the image upload form is submitted, the server response will appear in this iframe -->
8
+ var $div = $('<iframe id="iframe_user" name="iframe_user" width="100%" style="display:none"></iframe>').appendTo('body');
@@ -0,0 +1,16 @@
1
+ <% if @user.errors.blank? %>
2
+ $('#tr_user_<%= @user.id %>').replaceWith("<%= escape_javascript(render(:partial=>'/usman/admin/users/row', locals: {user: @user})) %>");
3
+ $("#tr_user_<%= @user.id %>").css("background-color", "#fffddd");
4
+ closeLargeModal();
5
+ <% else %>
6
+ // Show the form in the modal
7
+ heading = "Edit '<%= raw @user.name_was %>'";
8
+ bodyContent = "<%= escape_javascript(render(:partial=>'/usman/admin/users/form')) %>";
9
+ showLargeModal(heading, bodyContent);
10
+ var $div = $('<iframe id="iframe_user" name="iframe_user" width="100%" style="display:none"></iframe>').appendTo('body');
11
+ <%
12
+ text = "You have few errors. They have been highlighted."
13
+ error_message = content_tag(:div, text, class: "alert alert-danger")
14
+ %>
15
+ $("#user_form_error").html("<%= escape_javascript(error_message) %>");
16
+ <% end %>
@@ -0,0 +1,48 @@
1
+ <%= form_tag create_session_path, :role=>"form", id: "form_sign_in", class: "login-form fade-in-effect" do %>
2
+
3
+ <%= hidden_field_tag :customer_app, params[:customer_app] if params[:customer_app] %>
4
+
5
+ <%= hidden_field_tag :redirect_back_url, params[:redirect_back_url] if params[:redirect_back_url] %>
6
+
7
+ <%= hidden_field_tag :requested_url, params[:requested_url] if params[:requested_url] %>
8
+
9
+ <div class="row pt-10">
10
+ <div class="col-sm-offset-3 col-sm-4">
11
+ <img src="/assets/kuppayam/logo.png" alt="" width="180" />
12
+ </div>
13
+ </div>
14
+
15
+ <div class="login-header text-center">
16
+ <p>Sign in to access the admin area!</p>
17
+ </div>
18
+
19
+ <div class="form-group">
20
+ <label class="control-label" for="login_handle">Email / Username</label>
21
+ <%= text_field_tag :email, params[:login_handle], :placeholder=> "Email / Username", :name => "login_handle", :class=>"form-control", autocomplete: "off" %>
22
+ </div>
23
+
24
+ <div class="form-group">
25
+ <label class="control-label" for="password">Password</label>
26
+ <%= password_field_tag :password, '', :placeholder=> "Password", :name => "password", :class=>"form-control", id: "password", autocomplete: "off" %>
27
+ </div>
28
+
29
+ <div class="form-group">
30
+ <button type="submit" class="btn btn-primary btn-block text-left">
31
+ <i class="fa-lock"></i>
32
+ Sign In
33
+ </button>
34
+ </div>
35
+
36
+ <!-- <div class="login-footer">
37
+ <%#= link_to 'Forgot your password?', forgot_password_form_path %>
38
+
39
+ <div class="info-links">
40
+ <a href="#">ToS</a> -
41
+ <a href="#">Privacy Policy</a>
42
+ </div>
43
+
44
+ </div> -->
45
+
46
+ <% end %>
47
+
48
+
@@ -0,0 +1,3 @@
1
+ heading = "Please Sign In";
2
+ bodyContent = "<%= escape_javascript(render(:partial=>'usman/sessions/form.html.erb', locals: {redirect_back_url: request.original_url})) %>";
3
+ showGenericModal(heading, bodyContent);
@@ -0,0 +1,63 @@
1
+ <div class="login-container">
2
+
3
+ <div class="row">
4
+
5
+ <div class="col-sm-offset-3 col-sm-6">
6
+
7
+ <% if defined?(flash) %>
8
+ <!-- Errors container -->
9
+ <div class="errors-container">
10
+ <%= flash_message(false) -%>
11
+ </div>
12
+ <% end %>
13
+
14
+ <!-- Add class "fade-in-effect" for login form effect -->
15
+ <%= render partial: "usman/sessions/form" %>
16
+
17
+ </div>
18
+
19
+ </div>
20
+
21
+ </div>
22
+
23
+ <script type="text/javascript">
24
+ jQuery(document).ready(function($)
25
+ {
26
+ // Reveal Login form
27
+ setTimeout(function(){ $(".fade-in-effect").addClass('in'); }, 1);
28
+
29
+ // Validation and Ajax action
30
+ $("form#form_sign_in").validate({
31
+ rules: {
32
+ login_handle: {
33
+ required: true
34
+ },
35
+
36
+ password: {
37
+ required: true
38
+ }
39
+ },
40
+
41
+ messages: {
42
+ login_handle: {
43
+ required: 'Please enter your username or email.'
44
+ },
45
+
46
+ password: {
47
+ required: 'Please enter your password.'
48
+ }
49
+ },
50
+
51
+ // Form Processing via AJAX
52
+ submitHandler: function(form)
53
+ {
54
+ form.submit();
55
+ }
56
+ });
57
+
58
+ // Set Form focus
59
+ $("form#form_sign_in .form-group:has(.form-control):first .form-control").focus();
60
+ });
61
+ </script>
62
+
63
+
@@ -0,0 +1,61 @@
1
+ en:
2
+ response:
3
+ validation_error: "Sorry, there are errors with the information you provided. Please review the data you have entered."
4
+ failed_to_create_error: "Failed to create %{item}."
5
+ failed_to_update_error: "Failed to update %{item}."
6
+ failed_to_delete_error: "Failed to remove %{item}."
7
+ invalid_login_error: "Invalid username/email or password."
8
+ authentication_error: "Permission Denied: You don't have permission to perform this action"
9
+ created_successfully: "%{item} has been created successfully."
10
+ updated_successfully: "%{item} has been updated successfully."
11
+ removed_successfully: "%{item} has been removed successfully."
12
+ no_results_found: "No results found."
13
+ status:
14
+ internal_server_error: "500 - Something went wrong."
15
+ forbidden: "403 - Permission Denied! You don't have permission to perform this action."
16
+ not_found: "404 - Not Found: We don't have what you are looking for."
17
+ users:
18
+ masquerade: "You have successfully signed in as %{user}"
19
+ sign_in_back: "You have successfully signed in back as %{user}"
20
+ authentication:
21
+ error: "Error!"
22
+ success: "Success!"
23
+ login: "Sign in"
24
+ logout: "Sign out"
25
+ permission_denied:
26
+ heading: "Permission Denied"
27
+ message: "You don't have permission to perform this action"
28
+ session_expired:
29
+ heading: "Session Expired"
30
+ message: "Your session has been expired. Please sign in again"
31
+ invalid_token:
32
+ heading: "Invalid Token"
33
+ message: "You don't have permission to perform this action"
34
+ invalid_login:
35
+ heading: "Invalid Login"
36
+ message: "Invalid Username/Email or password."
37
+ user_is_pending:
38
+ heading: "Account Pending"
39
+ message: "Your account is not yet approved, please contact administrator to activate your account"
40
+ user_is_suspended:
41
+ heading: "Account Suspended"
42
+ message: "Your account is suspended, please contact administrator"
43
+ logged_in:
44
+ heading: "Signed In"
45
+ message: "You have successfully signed in"
46
+ logged_out:
47
+ heading: "Signed Out"
48
+ message: "You have successfully signed out"
49
+ forms:
50
+ add: "%{item} has been added successfully."
51
+ create: "%{item} has been created successfully."
52
+ save: "%{item} has been saved successfully."
53
+ update: "%{item} has been updated successfully."
54
+ delete: "%{item} has been deleted successfully."
55
+ remove: "%{item} has been removed successfully."
56
+ error: "Failed to create %{item}."
57
+ no_results: "No results found."
58
+ status:
59
+ internal_server_error: "500 Something went wrong."
60
+ forbidden: "403 Permission Denied! You don't have permission to perform this action."
61
+ not_found: "404 Not Found: We don't have what you are looking for."
data/config/routes.rb ADDED
@@ -0,0 +1,45 @@
1
+ Usman::Engine.routes.draw do
2
+
3
+ root :to => 'sessions#sign_in'
4
+
5
+ # Sign In URLs for users
6
+ get '/sign_in', to: "sessions#sign_in", as: :sign_in
7
+ post '/create_session', to: "sessions#create_session", as: :create_session
8
+ get '/forgot_password_form', to: "sessions#forgot_password_form", as: :forgot_password_form
9
+ post '/forgot_password', to: "sessions#forgot_password", as: :forgot_password
10
+ get '/reset_password_form/:id', to: "sessions#reset_password_form", as: :reset_password_form
11
+ put '/reset_password_update/:id', to: "sessions#reset_password_update", as: :reset_password_update
12
+
13
+ # Logout Url
14
+ delete '/sign_out' , to: "sessions#sign_out", as: :sign_out
15
+
16
+ namespace :admin do
17
+
18
+ get '/dashboard', to: "dashboard#index", as: :dashboard
19
+
20
+ resources :users do
21
+ member do
22
+ put :masquerade, as: :masquerade
23
+ put :update_status, as: :update_status
24
+ put :make_super_admin, as: :make_super_admin
25
+ put :remove_super_admin, as: :remove_super_admin
26
+ end
27
+ end
28
+
29
+ resources :features do
30
+ member do
31
+ put :update_status, as: :update_status
32
+ end
33
+ end
34
+
35
+ resources :permissions
36
+
37
+ resources :images do
38
+ member do
39
+ put :crop
40
+ end
41
+ end
42
+
43
+ end
44
+
45
+ end
@@ -0,0 +1,12 @@
1
+ class CreateImages < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :images do |t|
4
+ t.string :image
5
+ t.integer :imageable_id
6
+ t.string :imageable_type
7
+ t.timestamps
8
+ end
9
+
10
+ add_index(:images, [ :imageable_id, :imageable_type ])
11
+ end
12
+ end
@@ -0,0 +1,57 @@
1
+ class CreateUsers < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table(:users) do |t|
4
+
5
+ ## First Name, Last Name and Username
6
+ t.string :name, limit: 256
7
+ t.string :username, :null => false, :limit=>32
8
+ t.string :email, :null => false
9
+ t.string :phone, :null => true, :limit=>24
10
+ t.string :designation, :null => true, :limit=>56
11
+
12
+ t.boolean :super_admin, :null => true, default: false
13
+
14
+ t.string :status, :null => false, :default=>"pending", :limit=>16
15
+
16
+ ## Password Digest
17
+ t.string :password_digest, :null => false
18
+
19
+ ## Recoverable
20
+ t.string :reset_password_token
21
+ t.datetime :reset_password_sent_at
22
+
23
+ ## Rememberable
24
+ t.datetime :remember_created_at
25
+
26
+ ## Trackable
27
+ t.integer :sign_in_count, :default => 0
28
+ t.datetime :current_sign_in_at
29
+ t.datetime :last_sign_in_at
30
+ t.string :current_sign_in_ip
31
+ t.string :last_sign_in_ip
32
+
33
+ ## Confirmable
34
+ t.string :confirmation_token
35
+ t.datetime :confirmed_at
36
+ t.datetime :confirmation_sent_at
37
+ t.string :unconfirmed_email # Only if using reconfirmable
38
+
39
+ ## Lockable
40
+ t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
41
+ t.string :unlock_token # Only if unlock strategy is :email or :both
42
+ t.datetime :locked_at
43
+
44
+ ## Token authenticatable
45
+ t.string :auth_token
46
+ t.datetime :token_created_at, default: nil
47
+
48
+ t.timestamps
49
+ end
50
+
51
+ add_index :users, :email, :unique => true
52
+ add_index :users, :reset_password_token, :unique => true
53
+ add_index :users, :confirmation_token, :unique => true
54
+ add_index :users, :unlock_token, :unique => true
55
+ add_index :users, :auth_token, :unique => true
56
+ end
57
+ end