innetra-easy_authentication 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.
- data/Rakefile +14 -0
- data/easy_authentication.gemspec +32 -0
- data/generators/easy_authentication/easy_authentication_generator.rb +163 -0
- data/generators/easy_authentication/templates/controllers/roles_controller.rb +79 -0
- data/generators/easy_authentication/templates/controllers/sessions_controller.rb +44 -0
- data/generators/easy_authentication/templates/controllers/user_password_controller.rb +82 -0
- data/generators/easy_authentication/templates/controllers/user_roles_controller.rb +34 -0
- data/generators/easy_authentication/templates/controllers/users_controller.rb +72 -0
- data/generators/easy_authentication/templates/helpers/form_helper.rb +5 -0
- data/generators/easy_authentication/templates/helpers/shadowbox_helper.rb +23 -0
- data/generators/easy_authentication/templates/layouts/easy_authentication.erb +40 -0
- data/generators/easy_authentication/templates/layouts/easy_authentication_login.erb +22 -0
- data/generators/easy_authentication/templates/locales/en.easy_authentication.yml +84 -0
- data/generators/easy_authentication/templates/locales/es-MX.easy_authentication.yml +100 -0
- data/generators/easy_authentication/templates/migrations/easy_authentication.rb +54 -0
- data/generators/easy_authentication/templates/models/right.rb +2 -0
- data/generators/easy_authentication/templates/models/role.rb +12 -0
- data/generators/easy_authentication/templates/models/user.rb +3 -0
- data/generators/easy_authentication/templates/models/user_mailer.rb +0 -0
- data/generators/easy_authentication/templates/site_keys.rb +2 -0
- data/generators/easy_authentication/templates/stylesheets/default.css +249 -0
- data/generators/easy_authentication/templates/stylesheets/login.css +111 -0
- data/generators/easy_authentication/templates/stylesheets/roles.css +26 -0
- data/generators/easy_authentication/templates/stylesheets/users.css +21 -0
- data/generators/easy_authentication/templates/views/roles/_form.html.erb +37 -0
- data/generators/easy_authentication/templates/views/roles/edit.html.erb +19 -0
- data/generators/easy_authentication/templates/views/roles/index.html.erb +21 -0
- data/generators/easy_authentication/templates/views/roles/new.html.erb +19 -0
- data/generators/easy_authentication/templates/views/roles/show.html.erb +30 -0
- data/generators/easy_authentication/templates/views/sessions/new.html.erb +25 -0
- data/generators/easy_authentication/templates/views/user_password/edit.html.erb +35 -0
- data/generators/easy_authentication/templates/views/user_password/forgot_password.html.erb +16 -0
- data/generators/easy_authentication/templates/views/user_password/reset_password.html.erb +22 -0
- data/generators/easy_authentication/templates/views/user_roles/edit.html.erb +27 -0
- data/generators/easy_authentication/templates/views/users/_form.html.erb +47 -0
- data/generators/easy_authentication/templates/views/users/_user.html.erb +4 -0
- data/generators/easy_authentication/templates/views/users/edit.html.erb +14 -0
- data/generators/easy_authentication/templates/views/users/index.html.erb +21 -0
- data/generators/easy_authentication/templates/views/users/new.html.erb +14 -0
- data/generators/easy_authentication/templates/views/users/show.html.erb +53 -0
- data/init.rb +5 -0
- data/lib/controller_methods.rb +14 -0
- data/lib/cookie_authentication.rb +63 -0
- data/lib/helper_methods.rb +198 -0
- data/lib/password_authentication.rb +64 -0
- data/lib/user_methods.rb +109 -0
- data/tasks/rights.rake +35 -0
- data/tasks/sysadmin.rake +27 -0
- data/test/easy_authentication_test.rb +8 -0
- data/test/test_helper.rb +3 -0
- metadata +113 -0
@@ -0,0 +1,111 @@
|
|
1
|
+
a {
|
2
|
+
color: #4183c4;
|
3
|
+
}
|
4
|
+
|
5
|
+
h1 a,
|
6
|
+
a.red {
|
7
|
+
color: #f00;
|
8
|
+
}
|
9
|
+
|
10
|
+
body {
|
11
|
+
background: #F9F9F9;
|
12
|
+
color: #333;
|
13
|
+
font-family: helvetica, arial, clean, sans-serif;
|
14
|
+
font-size: 14px;
|
15
|
+
}
|
16
|
+
|
17
|
+
hr {
|
18
|
+
border: none;
|
19
|
+
border-bottom: #ccc dotted 1px;
|
20
|
+
height: 0;
|
21
|
+
}
|
22
|
+
|
23
|
+
label {
|
24
|
+
font-weight: bold;
|
25
|
+
}
|
26
|
+
|
27
|
+
p {
|
28
|
+
margin-left: 10px;
|
29
|
+
margin-right: 10px;
|
30
|
+
}
|
31
|
+
|
32
|
+
.container {
|
33
|
+
background-color: #fff;
|
34
|
+
border: #ddd solid 3px;
|
35
|
+
padding: 5px;
|
36
|
+
}
|
37
|
+
|
38
|
+
/* Flash */
|
39
|
+
|
40
|
+
.flash {
|
41
|
+
border: 3px solid;
|
42
|
+
font-weight: bold;
|
43
|
+
padding: 5px;
|
44
|
+
margin: 0 3px 10px 0;
|
45
|
+
}
|
46
|
+
|
47
|
+
.flash {
|
48
|
+
background-color: #FFFFE0;
|
49
|
+
border-color: #ffa82a;
|
50
|
+
color: #ff9d0d;
|
51
|
+
}
|
52
|
+
|
53
|
+
.flash.error {
|
54
|
+
background-color: #FFFFE0;
|
55
|
+
border-color: #f00;
|
56
|
+
color: #f00;
|
57
|
+
}
|
58
|
+
|
59
|
+
/* Shadow Effect */
|
60
|
+
.shadow {
|
61
|
+
margin-left: 3px;
|
62
|
+
margin-top: 3px;
|
63
|
+
}
|
64
|
+
|
65
|
+
.shadow .shadow1,
|
66
|
+
.shadow .shadow2,
|
67
|
+
.shadow .shadow3,
|
68
|
+
.sadow .container {
|
69
|
+
position: relative;
|
70
|
+
left: -1px;
|
71
|
+
top: -1px;
|
72
|
+
}
|
73
|
+
|
74
|
+
.shadow1 {
|
75
|
+
background-color: #c9c9c9;
|
76
|
+
}
|
77
|
+
|
78
|
+
.shadow2 {
|
79
|
+
background-color: #b0b0b0;
|
80
|
+
}
|
81
|
+
|
82
|
+
.shadow3 {
|
83
|
+
background-color: #a9a9a9;
|
84
|
+
}
|
85
|
+
|
86
|
+
input[type=text],
|
87
|
+
input[type=password] {
|
88
|
+
font-size: 24px;
|
89
|
+
width: 97%;
|
90
|
+
}
|
91
|
+
|
92
|
+
#login_form,
|
93
|
+
#forgot_password_form,
|
94
|
+
#reset_password_form {
|
95
|
+
margin: 7em auto;
|
96
|
+
text-align: center;
|
97
|
+
width: 325px;
|
98
|
+
}
|
99
|
+
|
100
|
+
#forgot_password_form .container,
|
101
|
+
#reset_password_form .container {
|
102
|
+
padding-bottom: 40px;
|
103
|
+
}
|
104
|
+
|
105
|
+
.container {
|
106
|
+
text-align: left;
|
107
|
+
}
|
108
|
+
|
109
|
+
#submit_button {
|
110
|
+
float: right;
|
111
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/* roles/index */
|
2
|
+
.role h3 a {
|
3
|
+
font-size: 18px;
|
4
|
+
padding: 10px 0;
|
5
|
+
}
|
6
|
+
|
7
|
+
/* roles/new|show|edit */
|
8
|
+
table.role {
|
9
|
+
width: 97%;
|
10
|
+
}
|
11
|
+
|
12
|
+
table.role td {
|
13
|
+
padding: 10px;
|
14
|
+
padding-bottom: 20px;
|
15
|
+
padding-top: 0px;
|
16
|
+
}
|
17
|
+
|
18
|
+
table.role.list li {
|
19
|
+
list-style-type: disc;
|
20
|
+
}
|
21
|
+
|
22
|
+
.rights {
|
23
|
+
min-width: 80px;
|
24
|
+
border: 1px dotted #ccc;
|
25
|
+
background-color: #f5f5f5;
|
26
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<p>
|
2
|
+
<%%= form.label :name %><br />
|
3
|
+
<%%= form.text_field :name, :size => "50" %>
|
4
|
+
</p>
|
5
|
+
<hr />
|
6
|
+
<p>
|
7
|
+
<%%= form.label :description %><br />
|
8
|
+
<%%= form.text_area :description, :size => "60x3" %>
|
9
|
+
</p>
|
10
|
+
<h2><%%= t("roles.assigned_rights") %></h2>
|
11
|
+
|
12
|
+
<table class="role" cellspacing="10px">
|
13
|
+
<%% @right_groups.in_groups_of(5) do |group| -%>
|
14
|
+
<tr>
|
15
|
+
<%% group.each do |name, rights| %>
|
16
|
+
<td class="rights">
|
17
|
+
<h3><%%= name %></h3>
|
18
|
+
<ul>
|
19
|
+
<%% if rights -%>
|
20
|
+
<%% for right in rights -%>
|
21
|
+
<li>
|
22
|
+
<%% if @role.new_record? -%>
|
23
|
+
<%%= check_box_tag "role[right_ids][]", right.id %>
|
24
|
+
<%% else -%>
|
25
|
+
<%%= check_box_tag "role[right_ids][]", right.id,
|
26
|
+
@role.rights.include?(right) %>
|
27
|
+
<%% end -%>
|
28
|
+
<%%= right.action_name %>
|
29
|
+
</li>
|
30
|
+
<%% end -%>
|
31
|
+
<%% end -%>
|
32
|
+
</ul>
|
33
|
+
</td>
|
34
|
+
<%% end -%>
|
35
|
+
</tr>
|
36
|
+
<%% end -%>
|
37
|
+
</table>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%% content_for :header do -%>
|
2
|
+
<%%= stylesheet_link_tag "easy_authentication/roles", :media => :all %>
|
3
|
+
<%% end -%>
|
4
|
+
|
5
|
+
<h1>
|
6
|
+
<div class="title_actions">
|
7
|
+
<%%= link_to t("forms.cancel"), @role %>
|
8
|
+
</div>
|
9
|
+
<%%= t("roles.edit.title", :name => @role.name) %>
|
10
|
+
</h1>
|
11
|
+
|
12
|
+
<%% form_for @role do |form| %>
|
13
|
+
<%%= render :partial => form %>
|
14
|
+
<hr />
|
15
|
+
<p>
|
16
|
+
<%%= submit_tag t("forms.update") %> ó
|
17
|
+
<%%= link_to t("forms.cancel"), roles_url, :class => :red %>
|
18
|
+
</p>
|
19
|
+
<%% end %>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%% content_for :header do -%>
|
2
|
+
<%%= stylesheet_link_tag "easy_authentication/roles", :media => :all %>
|
3
|
+
<%% end -%>
|
4
|
+
|
5
|
+
<%% content_for :sidebar do -%>
|
6
|
+
<%% shadowbox "roles_actions", :class => "sidebar_section" do %>
|
7
|
+
<%%= link_to t("roles.index.new_role_link"), new_role_url %>
|
8
|
+
<%% end %>
|
9
|
+
<%% end -%>
|
10
|
+
|
11
|
+
<h1><%%= t("roles.index.title") %></h1>
|
12
|
+
<ul>
|
13
|
+
<%% for role in @roles -%>
|
14
|
+
<%% content_tag_for(:li, role) do -%>
|
15
|
+
<h3><%%= link_to role.name, role %></h3>
|
16
|
+
<%% unless role.description.blank? -%>
|
17
|
+
<%%= role.description %>
|
18
|
+
<%% end -%>
|
19
|
+
<%% end -%>
|
20
|
+
<%% end -%>
|
21
|
+
</ul>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%% content_for :header do -%>
|
2
|
+
<%%= stylesheet_link_tag "easy_authentication/roles", :media => :all %>
|
3
|
+
<%% end -%>
|
4
|
+
|
5
|
+
<h1>
|
6
|
+
<div class="title_actions">
|
7
|
+
<%%= link_to t("forms.cancel"), roles_url %>
|
8
|
+
</div>
|
9
|
+
<%%= t("roles.new.title") %>
|
10
|
+
</h1>
|
11
|
+
|
12
|
+
<%% form_for @role do |form| %>
|
13
|
+
<%%= render :partial => form %>
|
14
|
+
<hr />
|
15
|
+
<p>
|
16
|
+
<%%= submit_tag t("forms.save") %> ó
|
17
|
+
<%%= link_to t("forms.cancel"), roles_url, :class => :red %>
|
18
|
+
</p>
|
19
|
+
<%% end %>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<%% content_for :header do -%>
|
2
|
+
<%%= stylesheet_link_tag "easy_authentication/roles", :media => :all %>
|
3
|
+
<%% end -%>
|
4
|
+
|
5
|
+
<h1>
|
6
|
+
<div class="title_actions">
|
7
|
+
<%%= link_to t("roles.show.edit_link"), edit_role_url(@role) %> |
|
8
|
+
<%%= link_to t("roles.show.back_link"), roles_url %>
|
9
|
+
</div>
|
10
|
+
<%%= t("roles.show.title", :name => @role.name) %>
|
11
|
+
</h1>
|
12
|
+
|
13
|
+
<table class="role list" cellspacing="10px">
|
14
|
+
<%% @right_groups.in_groups_of(5) do |group| -%>
|
15
|
+
<tr>
|
16
|
+
<%% group.each do |name, rights| %>
|
17
|
+
<%% if rights -%>
|
18
|
+
<td class="rights">
|
19
|
+
<h3><%%= name %></h3>
|
20
|
+
<ul>
|
21
|
+
<%% for right in rights -%>
|
22
|
+
<li><%%= right.action_name %></li>
|
23
|
+
<%% end -%>
|
24
|
+
</ul>
|
25
|
+
</td>
|
26
|
+
<%% end -%>
|
27
|
+
<%% end -%>
|
28
|
+
</tr>
|
29
|
+
<%% end -%>
|
30
|
+
</table>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<%% content_for :header do -%>
|
2
|
+
<%%= stylesheet_link_tag "easy_authentication/login", :media => :all %>
|
3
|
+
<%% end -%>
|
4
|
+
|
5
|
+
|
6
|
+
<%% shadowbox "login_form" do %>
|
7
|
+
<%% form_tag sessions_url do -%>
|
8
|
+
<p>
|
9
|
+
<%%= label_tag t("sessions.new.login") %><br />
|
10
|
+
<%%= text_field_tag 'login', @login %>
|
11
|
+
</p>
|
12
|
+
<p>
|
13
|
+
<%%= label_tag t("sessions.new.password") %><br/>
|
14
|
+
<%%= password_field_tag 'password', nil %>
|
15
|
+
</p>
|
16
|
+
<p>
|
17
|
+
<%%= submit_tag t("sessions.new.submit_button"), :id => "submit_button" %>
|
18
|
+
<%%= check_box_tag "remember_me", "1", @remember_me %>
|
19
|
+
<span><%%= t("sessions.new.remember_me") %></span>
|
20
|
+
</p>
|
21
|
+
<hr />
|
22
|
+
<p><%%= link_to t("sessions.new.recover_password"),
|
23
|
+
forgot_password_url, :class => :red %></p>
|
24
|
+
<%% end -%>
|
25
|
+
<%% end -%>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<%% content_for :header do -%>
|
2
|
+
<%%= stylesheet_link_tag "easy_authentication/user_password", :media => :all %>
|
3
|
+
<%% end -%>
|
4
|
+
|
5
|
+
<h1>
|
6
|
+
<div class="title_actions">
|
7
|
+
<%%= link_to t("forms.cancel"), home_url %>
|
8
|
+
</div>
|
9
|
+
<%%= t("user_password.edit.title", :full_name => @user.full_name, :login => @user.login) %>
|
10
|
+
</h1>
|
11
|
+
|
12
|
+
<%% form_for @user, :url => { :action => "update" } do |form| %>
|
13
|
+
<%%= error_messages_for :user %>
|
14
|
+
<p>
|
15
|
+
<%%= form.label :current_password %>
|
16
|
+
<%%= required_field %><br />
|
17
|
+
<%%= form.password_field :current_password %>
|
18
|
+
</p>
|
19
|
+
<h2><%%= t("user_password.edit.new_password") %></h2>
|
20
|
+
<p>
|
21
|
+
<%%= form.label :password %>
|
22
|
+
<%%= required_field %><br />
|
23
|
+
<%%= form.password_field :password %>
|
24
|
+
</p>
|
25
|
+
<p>
|
26
|
+
<%%= form.label :password_confirmation %>
|
27
|
+
<%%= required_field %><br />
|
28
|
+
<%%= form.password_field :password_confirmation %>
|
29
|
+
</p>
|
30
|
+
<hr />
|
31
|
+
<p>
|
32
|
+
<%%= submit_tag t("forms.save") %> ó
|
33
|
+
<%%= link_to t("forms.cancel"), home_url, :class => :red %>
|
34
|
+
</p>
|
35
|
+
<%% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<%% content_for :header do -%>
|
2
|
+
<%%= stylesheet_link_tag "easy_authentication/login", :media => :all %>
|
3
|
+
<%% end -%>
|
4
|
+
|
5
|
+
<%% shadowbox "forgot_password_form" do %>
|
6
|
+
<%% form_tag "/user_password/send_password_token" do -%>
|
7
|
+
<p>
|
8
|
+
<%%= label_tag t("user_password.forgot_password.login") %><br />
|
9
|
+
<%%= text_field_tag 'login', @login %>
|
10
|
+
</p>
|
11
|
+
<hr />
|
12
|
+
<p>
|
13
|
+
<%%= submit_tag t("user_password.forgot_password.submit_button"), :id => "submit_button" %>
|
14
|
+
</p>
|
15
|
+
<%% end -%>
|
16
|
+
<%% end -%>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<%% content_for :header do -%>
|
2
|
+
<%%= stylesheet_link_tag "easy_authentication/login", :media => :all %>
|
3
|
+
<%% end -%>
|
4
|
+
|
5
|
+
<%% shadowbox "reset_password_form" do %>
|
6
|
+
<%% form_for @user, :url => reset_password_url do |form| -%>
|
7
|
+
<%%= form.hidden_field :login %>
|
8
|
+
<%%= form.hidden_field :password_reset_token %>
|
9
|
+
<p>
|
10
|
+
<%%= form.label :password %><br />
|
11
|
+
<%%= form.password_field :password %>
|
12
|
+
</p>
|
13
|
+
<p>
|
14
|
+
<%%= form.label :password_confirmation %><br />
|
15
|
+
<%%= form.password_field :password_confirmation %>
|
16
|
+
</p>
|
17
|
+
<hr />
|
18
|
+
<p>
|
19
|
+
<%%= submit_tag t("user_password.reset_password.submit_button"), :id => "submit_button" %>
|
20
|
+
</p>
|
21
|
+
<%% end -%>
|
22
|
+
<%% end -%>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<%% content_for :header do -%>
|
2
|
+
<%%= stylesheet_link_tag "easy_authentication/user_roles", :media => :all %>
|
3
|
+
<%% end -%>
|
4
|
+
|
5
|
+
<h1>
|
6
|
+
<div class="title_actions">
|
7
|
+
<%%= link_to t("forms.cancel"), @user %>
|
8
|
+
</div>
|
9
|
+
<%%= t("user_roles.edit.title", :login => @user.login) %>
|
10
|
+
</h1>
|
11
|
+
|
12
|
+
<%% form_for @user do |form| %>
|
13
|
+
<ul id="roles">
|
14
|
+
<%% for role in @roles -%>
|
15
|
+
<%% content_tag_for(:li, role) do -%>
|
16
|
+
<%%= check_box_tag "user[role_ids][]", role.id,
|
17
|
+
@user.roles.include?(role) %>
|
18
|
+
<%%= role.name %>
|
19
|
+
<%% end -%>
|
20
|
+
<%% end -%>
|
21
|
+
</ul>
|
22
|
+
<hr />
|
23
|
+
<p>
|
24
|
+
<%%= submit_tag t("forms.save") %> ó
|
25
|
+
<%%= link_to t("forms.cancel"), @user, :class => :red %>
|
26
|
+
</p>
|
27
|
+
<%% end %>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<%%= error_messages_for :user %>
|
2
|
+
<table>
|
3
|
+
<tr>
|
4
|
+
<td>
|
5
|
+
<%%= form.label :first_name %>
|
6
|
+
<%%= required_field %><br />
|
7
|
+
<%%= form.text_field :first_name %>
|
8
|
+
</td>
|
9
|
+
<td>
|
10
|
+
<%%= form.label :last_name %>
|
11
|
+
<%%= required_field %><br />
|
12
|
+
<%%= form.text_field :last_name %>
|
13
|
+
</td>
|
14
|
+
</tr>
|
15
|
+
<table>
|
16
|
+
<hr />
|
17
|
+
<p>
|
18
|
+
<%%= form.label :email %>
|
19
|
+
<%%= required_field %><br />
|
20
|
+
<%%= form.text_field :email %>
|
21
|
+
</p>
|
22
|
+
<hr />
|
23
|
+
<%% if @user.new_record? -%>
|
24
|
+
<p>
|
25
|
+
<%%= form.label :login %>
|
26
|
+
<%%= required_field %><br />
|
27
|
+
<%%= form.text_field :login %><br />
|
28
|
+
<span class="comment"><%%= t "users.new.login_comment" %></span>
|
29
|
+
</p>
|
30
|
+
<hr />
|
31
|
+
<%% end -%>
|
32
|
+
<p>
|
33
|
+
<%%= form.label :password %>
|
34
|
+
<%%= required_field %><br />
|
35
|
+
<%%= form.password_field :password %><br />
|
36
|
+
<span class="comment"><%%= t "users.new.password_comment" %></span>
|
37
|
+
</p>
|
38
|
+
<p>
|
39
|
+
<%%= form.label :password_confirmation %>
|
40
|
+
<%%= required_field %><br />
|
41
|
+
<%%= form.password_field :password_confirmation %>
|
42
|
+
</p>
|
43
|
+
<hr />
|
44
|
+
<p>
|
45
|
+
<%%= submit_tag t("forms.save") %> ó
|
46
|
+
<%%= link_to t("forms.cancel"), users_url, :class => :red %>
|
47
|
+
</p>
|