authentasaurus 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +173 -0
- data/TODO +4 -0
- data/app/controllers/areas_controller.rb +4 -0
- data/app/controllers/groups_controller.rb +4 -0
- data/app/controllers/permissions_controller.rb +4 -0
- data/app/controllers/recoveries_controller.rb +2 -0
- data/app/controllers/registrations_controller.rb +2 -0
- data/app/controllers/sessions_controller.rb +2 -0
- data/app/controllers/user_invitations_controller.rb +4 -0
- data/app/controllers/users_controller.rb +4 -0
- data/app/controllers/validations_controller.rb +2 -0
- data/app/models/area.rb +2 -0
- data/app/models/authentasaurus_emailer.rb +2 -0
- data/app/models/group.rb +2 -0
- data/app/models/permission.rb +2 -0
- data/app/models/recovery.rb +2 -0
- data/app/models/session.rb +2 -0
- data/app/models/user.rb +3 -0
- data/app/models/user_invitation.rb +2 -0
- data/app/models/user_sync.rb +3 -0
- data/app/models/validation.rb +2 -0
- data/app/views/areas/edit.html.erb +7 -0
- data/app/views/areas/index.html.erb +11 -0
- data/app/views/areas/new.html.erb +7 -0
- data/app/views/areas/show.html.erb +7 -0
- data/app/views/authentasaurus_emailer/invitation_mail.html.erb +4 -0
- data/app/views/authentasaurus_emailer/recovery_mail.html.erb +7 -0
- data/app/views/authentasaurus_emailer/validation_mail.html.erb +6 -0
- data/app/views/groups/edit.html.erb +7 -0
- data/app/views/groups/index.html.erb +11 -0
- data/app/views/groups/new.html.erb +7 -0
- data/app/views/groups/show.html.erb +7 -0
- data/app/views/permissions/edit.html.erb +19 -0
- data/app/views/permissions/index.html.erb +17 -0
- data/app/views/permissions/new.html.erb +19 -0
- data/app/views/permissions/show.html.erb +7 -0
- data/app/views/recoveries/edit.html.erb +24 -0
- data/app/views/recoveries/new.html.erb +15 -0
- data/app/views/registrations/new.html.erb +21 -0
- data/app/views/sessions/new.html.erb +41 -0
- data/app/views/sessions/no_access.html.erb +1 -0
- data/app/views/user_invitations/index.html.erb +14 -0
- data/app/views/user_invitations/new.html.erb +9 -0
- data/app/views/users/edit.html.erb +27 -0
- data/app/views/users/index.html.erb +19 -0
- data/app/views/users/new.html.erb +27 -0
- data/app/views/users/show.html.erb +11 -0
- data/app/views/validations/activate.html.erb +6 -0
- data/app/views/validations/resend_validation_email.html.erb +6 -0
- data/config/locales/en.yml +34 -0
- data/generators/authentasaurus/USAGE +2 -0
- data/generators/authentasaurus/authentasaurus_generator.rb +9 -0
- data/generators/authentasaurus/templates/authentasaurus_tasks.rake +48 -0
- data/generators/authentasaurus/templates/defaults.yml +51 -0
- data/generators/authentasaurus/templates/initializer.rb +3 -0
- data/generators/authentasaurus_views/USAGE +12 -0
- data/generators/authentasaurus_views/authentasaurus_views_generator.rb +87 -0
- data/generators/authentasaurus_views/templates/views/areas/edit.html.erb +7 -0
- data/generators/authentasaurus_views/templates/views/areas/index.html.erb +11 -0
- data/generators/authentasaurus_views/templates/views/areas/new.html.erb +7 -0
- data/generators/authentasaurus_views/templates/views/areas/show.html.erb +7 -0
- data/generators/authentasaurus_views/templates/views/authentasaurus_emailer/invitation_mail.html.erb +4 -0
- data/generators/authentasaurus_views/templates/views/authentasaurus_emailer/recovery_mail.html.erb +7 -0
- data/generators/authentasaurus_views/templates/views/authentasaurus_emailer/validation_mail.html.erb +6 -0
- data/generators/authentasaurus_views/templates/views/groups/edit.html.erb +7 -0
- data/generators/authentasaurus_views/templates/views/groups/index.html.erb +11 -0
- data/generators/authentasaurus_views/templates/views/groups/new.html.erb +7 -0
- data/generators/authentasaurus_views/templates/views/groups/show.html.erb +7 -0
- data/generators/authentasaurus_views/templates/views/permissions/edit.html.erb +19 -0
- data/generators/authentasaurus_views/templates/views/permissions/index.html.erb +17 -0
- data/generators/authentasaurus_views/templates/views/permissions/new.html.erb +19 -0
- data/generators/authentasaurus_views/templates/views/permissions/show.html.erb +7 -0
- data/generators/authentasaurus_views/templates/views/recoveries/edit.html.erb +24 -0
- data/generators/authentasaurus_views/templates/views/recoveries/new.html.erb +15 -0
- data/generators/authentasaurus_views/templates/views/registrations/new.html.erb +21 -0
- data/generators/authentasaurus_views/templates/views/sessions/new.html.erb +41 -0
- data/generators/authentasaurus_views/templates/views/sessions/no_access.html.erb +1 -0
- data/generators/authentasaurus_views/templates/views/user_invitations/index.html.erb +14 -0
- data/generators/authentasaurus_views/templates/views/user_invitations/new.html.erb +9 -0
- data/generators/authentasaurus_views/templates/views/users/edit.html.erb +27 -0
- data/generators/authentasaurus_views/templates/views/users/index.html.erb +19 -0
- data/generators/authentasaurus_views/templates/views/users/new.html.erb +27 -0
- data/generators/authentasaurus_views/templates/views/users/show.html.erb +11 -0
- data/generators/authentasaurus_views/templates/views/validations/activate.html.erb +6 -0
- data/generators/authentasaurus_views/templates/views/validations/resend_validation_email.html.erb +6 -0
- data/lib/action_controller/authorization.rb +215 -0
- data/lib/action_view/authorization.rb +123 -0
- data/lib/active_record/acts_as_authenticatable.rb +80 -0
- data/lib/active_record/acts_as_authenticatable_validatable.rb +32 -0
- data/lib/active_record/authenticatable.rb +56 -0
- data/lib/active_resource/acts_as_authenticatable.rb +42 -0
- data/lib/active_resource/authenticatable.rb +22 -0
- data/lib/authentasaurus.rb +21 -0
- data/lib/authentasaurus/areas_controller.rb +71 -0
- data/lib/authentasaurus/authentasaurus_controller.rb +2 -0
- data/lib/authentasaurus/groups_controller.rb +73 -0
- data/lib/authentasaurus/models/area.rb +8 -0
- data/lib/authentasaurus/models/authentasaurus_emailer.rb +31 -0
- data/lib/authentasaurus/models/group.rb +8 -0
- data/lib/authentasaurus/models/permission.rb +9 -0
- data/lib/authentasaurus/models/recovery.rb +23 -0
- data/lib/authentasaurus/models/session.rb +63 -0
- data/lib/authentasaurus/models/user_invitation.rb +21 -0
- data/lib/authentasaurus/models/validation.rb +18 -0
- data/lib/authentasaurus/permissions_controller.rb +71 -0
- data/lib/authentasaurus/recoveries_controller.rb +59 -0
- data/lib/authentasaurus/registrations_controller.rb +32 -0
- data/lib/authentasaurus/sessions_controller.rb +45 -0
- data/lib/authentasaurus/user_invitations_controller.rb +39 -0
- data/lib/authentasaurus/users_controller.rb +71 -0
- data/lib/authentasaurus/validations_controller.rb +34 -0
- data/lib/helpers/migrations.rb +171 -0
- data/lib/helpers/routing.rb +90 -0
- data/rails/init.rb +37 -0
- metadata +188 -0
@@ -0,0 +1,7 @@
|
|
1
|
+
<h1><%= @permission.area.name %> permissions for <%= @permission.group.name %></h1>
|
2
|
+
<% if @permission.read %>
|
3
|
+
<h3>Members of <%= @permission.group.name %> have read permission for <%= @permission.area.name %></h3>
|
4
|
+
<% end %>
|
5
|
+
<% if @permission.write %>
|
6
|
+
<h3>Members of <%= @permission.group.name %> have write permission for <%= @permission.area.name %></h3>
|
7
|
+
<% end %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<h1>Fill in your new password</h1>
|
2
|
+
|
3
|
+
<% form_tag do_recover_password_path, :method => :delete do %>
|
4
|
+
<%= error_messages_for :user %>
|
5
|
+
|
6
|
+
<p>
|
7
|
+
<%= label_tag :name %><br />
|
8
|
+
<%= text_field_tag :name, @user.name, :disabled => true %>
|
9
|
+
</p>
|
10
|
+
|
11
|
+
<p>
|
12
|
+
<%= label_tag "user[new_password]", "Password" %><br />
|
13
|
+
<%= password_field_tag "user[new_password]" %>
|
14
|
+
</p>
|
15
|
+
<p>
|
16
|
+
<%= label_tag "user[new_password_confirmation]", "Password confirmation" %><br />
|
17
|
+
<%= password_field_tag "user[new_password_confirmation]" %>
|
18
|
+
</p>
|
19
|
+
<p>
|
20
|
+
<%= submit_tag "Set" %>
|
21
|
+
</p>
|
22
|
+
<% end %>
|
23
|
+
|
24
|
+
<%= link_to "Cancel", url_for(:back) %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<h1>Recover your password</h1>
|
2
|
+
|
3
|
+
<% form_for @recovery, :url => do_forgot_password_path do |f| %>
|
4
|
+
<%= f.error_messages %>
|
5
|
+
<p>
|
6
|
+
<%= f.label :email %><br />
|
7
|
+
<%= f.text_field :email %>
|
8
|
+
</p>
|
9
|
+
|
10
|
+
<p>
|
11
|
+
<%= f.submit "Send Instructions" %>
|
12
|
+
</p>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<%= link_to "Cancel", url_for(:back) %>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<h1>Enter your data</h1>
|
2
|
+
<% form_for @user, :url => registrations_path(:token => params[:token]) do |f| %>
|
3
|
+
<%= f.error_messages %>
|
4
|
+
<br>
|
5
|
+
<%= f.label :username %>
|
6
|
+
<%= f.text_field :username, :size => 30 %>
|
7
|
+
<br>
|
8
|
+
<%= f.label :password %>
|
9
|
+
<%= f.password_field :password, :size => 30 %>
|
10
|
+
<br>
|
11
|
+
<%= f.label :password_confirmation %>
|
12
|
+
<%= f.password_field :password_confirmation, :size => 30 %>
|
13
|
+
<br>
|
14
|
+
<%= f.label :name %>
|
15
|
+
<%= f.text_field :name, :size => 30 %>
|
16
|
+
<br>
|
17
|
+
<%= f.label :email %>
|
18
|
+
<%= f.text_field :email, :size => 30 %>
|
19
|
+
<br>
|
20
|
+
<%= f.submit "Create" %>
|
21
|
+
<% end %>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<div class="form-stroke">
|
2
|
+
<%= flash[:alert] if flash[:alert] %>
|
3
|
+
<% form_for @session do |f| %>
|
4
|
+
<h2>Sign in</h2>
|
5
|
+
<br>
|
6
|
+
<%= f.error_messages %>
|
7
|
+
<p>
|
8
|
+
<%= f.label :username %>
|
9
|
+
<%= f.text_field :username, :style => "width: 98%;" %>
|
10
|
+
</p>
|
11
|
+
|
12
|
+
<p>
|
13
|
+
<%= f.label :password %>
|
14
|
+
<%= f.password_field :password, :style => "width: 98%;" %>
|
15
|
+
</p>
|
16
|
+
|
17
|
+
<label>
|
18
|
+
<%= f.check_box :remember %> Remember me
|
19
|
+
</label>
|
20
|
+
|
21
|
+
<div>
|
22
|
+
<div style="float:left; padding-top: 9px;">
|
23
|
+
<% unless defined?(forgot_password_path).nil? %>
|
24
|
+
<p>
|
25
|
+
<%= link_to(t(:forgot_password_link, :scope => [:authentasaurus, :views, :sessions]), forgot_password_path) %>
|
26
|
+
</p>
|
27
|
+
<% end %>
|
28
|
+
|
29
|
+
<% unless defined?(resend_validation_email_path).nil? %>
|
30
|
+
<p>
|
31
|
+
<%= link_to(t(:resend_validation_email_link, :scope => [:authentasaurus, :views, :sessions]), resend_validation_email_path) %>
|
32
|
+
</p>
|
33
|
+
<% end %>
|
34
|
+
</div>
|
35
|
+
<div style="float:right;">
|
36
|
+
<%= submit_tag "Sign in" %>
|
37
|
+
</div>
|
38
|
+
<br style="clear: both;">
|
39
|
+
</div>
|
40
|
+
<% end %>
|
41
|
+
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>You are not allowed to access this page.</h1>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<h1>User Invitations</h1>
|
2
|
+
<table width="100%">
|
3
|
+
<tr>
|
4
|
+
<th>Email</th>
|
5
|
+
</tr>
|
6
|
+
<% @invitations.each do |invitation| %>
|
7
|
+
<tr>
|
8
|
+
<td><%= invitation.email %></td>
|
9
|
+
<td><%= link_to "Delete", invitation, :method => :delete, :confirm => "Are you sure?" %></td>
|
10
|
+
</tr>
|
11
|
+
<% end %>
|
12
|
+
</table>
|
13
|
+
<br>
|
14
|
+
<%= link_to "New", :action => :new %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<h1>Editing <%= @user.username %></h1>
|
2
|
+
<% form_for @user do |f| %>
|
3
|
+
<%= f.error_messages %>
|
4
|
+
<br>
|
5
|
+
<%= f.label :username %>
|
6
|
+
<%= f.text_field :username, :size => 30 %>
|
7
|
+
<br>
|
8
|
+
<%= f.label :new_password %>
|
9
|
+
<%= f.password_field :new_password, :size => 30 %>
|
10
|
+
<br>
|
11
|
+
<%= f.label :new_password_confirmation %>
|
12
|
+
<%= f.password_field :new_password_confirmation, :size => 30 %>
|
13
|
+
<br>
|
14
|
+
<%= f.label :name %>
|
15
|
+
<%= f.text_field :name, :size => 30 %>
|
16
|
+
<br>
|
17
|
+
<%= f.label :email %>
|
18
|
+
<%= f.text_field :email, :size => 30 %>
|
19
|
+
<br>
|
20
|
+
<%= f.label :active %>
|
21
|
+
<%= f.check_box :active %>
|
22
|
+
<br>
|
23
|
+
<%= f.label :group_id %>
|
24
|
+
<%= f.collection_select(:group_id, Group.find(:all), :id, :name, {:prompt => true}) %>
|
25
|
+
<br>
|
26
|
+
<%= f.submit "Create" %>
|
27
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<h1>Users</h1>
|
2
|
+
<table width="100%">
|
3
|
+
<tr>
|
4
|
+
<th>Username</th>
|
5
|
+
<th>Name</th>
|
6
|
+
<th>Email</th>
|
7
|
+
<th>Active</th>
|
8
|
+
<th>Group</th>
|
9
|
+
</tr>
|
10
|
+
<% @users.each do |user| %>
|
11
|
+
<tr>
|
12
|
+
<td><%= link_to user.username, user %></td>
|
13
|
+
<td><%= user.name %></td>
|
14
|
+
<td><%= user.email %></td>
|
15
|
+
<td><%= check_box_tag user.id, "active", user.active, :disabled => true %></td>
|
16
|
+
<td><%= link_to user.group.name, user.group %></td>
|
17
|
+
</tr>
|
18
|
+
<% end %>
|
19
|
+
</table>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<h1>Create new user</h1>
|
2
|
+
<% form_for @user do |f| %>
|
3
|
+
<%= f.error_messages %>
|
4
|
+
<br>
|
5
|
+
<%= f.label :username %>
|
6
|
+
<%= f.text_field :username, :size => 30 %>
|
7
|
+
<br>
|
8
|
+
<%= f.label :password %>
|
9
|
+
<%= f.password_field :password, :size => 30 %>
|
10
|
+
<br>
|
11
|
+
<%= f.label :password_confirmation %>
|
12
|
+
<%= f.password_field :password_confirmation, :size => 30 %>
|
13
|
+
<br>
|
14
|
+
<%= f.label :name %>
|
15
|
+
<%= f.text_field :name, :size => 30 %>
|
16
|
+
<br>
|
17
|
+
<%= f.label :email %>
|
18
|
+
<%= f.text_field :email, :size => 30 %>
|
19
|
+
<br>
|
20
|
+
<%= f.label :active %>
|
21
|
+
<%= f.check_box :active %>
|
22
|
+
<br>
|
23
|
+
<%= f.label :group_id %>
|
24
|
+
<%= f.collection_select(:group_id, Group.find(:all), :id, :name, {:prompt => true}) %>
|
25
|
+
<br>
|
26
|
+
<%= f.submit "Create" %>
|
27
|
+
<% end %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<h1><%= @user.username %></h1>
|
2
|
+
<dl>
|
3
|
+
<dt>Name : </dt>
|
4
|
+
<dd><%= @user.name %></dd>
|
5
|
+
<dt>Email : </dt>
|
6
|
+
<dd><%= @user.email %></dd>
|
7
|
+
<dt>Active : </dt>
|
8
|
+
<dd><%= check_box_tag @user.id, "active", @user.active, :disabled => true %></dd>
|
9
|
+
<dt>Group : </dt>
|
10
|
+
<dd><%= link_to @user.group.name, @user.group %></dd>
|
11
|
+
</dl>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
en:
|
2
|
+
activerecord:
|
3
|
+
errors:
|
4
|
+
full_messages:
|
5
|
+
authenticatable:
|
6
|
+
lower_case_password: "Your password must include at least one lower case character"
|
7
|
+
upper_case_password: "Your password must include at least one upper case character"
|
8
|
+
digit_password: "Your password must include at least one digit"
|
9
|
+
symbol_password: "Your password must include at least one of the following symbols \"@$%!&\""
|
10
|
+
recovery:
|
11
|
+
user_id:
|
12
|
+
blank: "There exists no user with the given email"
|
13
|
+
authentasaurus:
|
14
|
+
messages:
|
15
|
+
sessions:
|
16
|
+
invalid_login: Invalid Username/Password combination
|
17
|
+
validations:
|
18
|
+
validation_successful: Account activated successfully
|
19
|
+
validation_failed: Validation failed, check your validation code and try again
|
20
|
+
validation_email_sent: A message containing instructions to validate your email has been sent to your email
|
21
|
+
validation_email_invalid: Could not find {{email}}
|
22
|
+
recoveries:
|
23
|
+
recovery_successful: Password recovered successfully
|
24
|
+
recovery_failed: Token no longer valid
|
25
|
+
recovery_email_sent: A message containing instructions to recover your password has been sent to {{email}}
|
26
|
+
recovery_email_invalid: Email format is invalid
|
27
|
+
recovery_email_unknown: Email does not exist
|
28
|
+
recovery_field_blank: "{{field}} can't be blank"
|
29
|
+
user_invitations:
|
30
|
+
invalid_invitation_token: Invalid invitation token
|
31
|
+
views:
|
32
|
+
sessions:
|
33
|
+
resend_validation_email_link: Haven't recieved your validation email?
|
34
|
+
forgot_password_link: Forgot your password?
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class AuthentasaurusGenerator < Rails::Generator::Base
|
2
|
+
def manifest
|
3
|
+
record do |m|
|
4
|
+
m.file "initializer.rb", File.join("config", "initializers", "authentasaurus.rb")
|
5
|
+
m.file "defaults.yml", File.join("config", "authentasaurus.yml")
|
6
|
+
m.file "authentasaurus_tasks.rake", File.join("lib","tasks","authentasaurus.rake")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
namespace :authentasaurus do
|
2
|
+
desc "Setup default data for authentasaurus"
|
3
|
+
task :setup_defaults => :environment do
|
4
|
+
puts "Setting default data"
|
5
|
+
unless ENV["authorizable"] == "false"
|
6
|
+
puts "- Creating Areas"
|
7
|
+
area = Area.create! :name => "all"
|
8
|
+
create_areas
|
9
|
+
puts "- Creating Administrators group"
|
10
|
+
group = Group.create! :name => "Administrators"
|
11
|
+
puts "- Creating permissions"
|
12
|
+
Permission.create! :area_id => area.id, :group_id => group.id, :write => true, :read => true
|
13
|
+
puts "- Creating default user"
|
14
|
+
User.create! :username=> "admin" ,:password => "Pass@123",:password_confirmation => "Pass@123",:name=> "admin",
|
15
|
+
:email=> AUTHENTASAURUS[:mail][:email], :active => true, :group_id => group.id
|
16
|
+
else
|
17
|
+
puts "- Creating default user"
|
18
|
+
User.create! :username=> "admin" ,:password => "Pass@123",:password_confirmation => "Pass@123",:name=> "admin",
|
19
|
+
:email=> AUTHENTASAURUS[:mail][:email], :active => true
|
20
|
+
end
|
21
|
+
|
22
|
+
puts "Created admin user, you can now login with the following credentials:"
|
23
|
+
puts ""
|
24
|
+
puts "Username: admin"
|
25
|
+
puts "Password: Pass@123"
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Finds and creates areas for use in authorization"
|
29
|
+
task :create_areas => :environment do
|
30
|
+
create_areas
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_areas
|
34
|
+
puts "-- Locating areas"
|
35
|
+
controllers = Dir.new("#{RAILS_ROOT}/app/controllers").entries
|
36
|
+
controllers.each do |controller|
|
37
|
+
if controller =~ /_controller/ && !(controller =~ /application_controller/)
|
38
|
+
cont = controller.gsub("_controller.rb","")
|
39
|
+
puts "--- Creating #{cont} area"
|
40
|
+
area = Area.find_or_create_by_name cont
|
41
|
+
unless area.errors.empty?
|
42
|
+
puts area.errors.full_messages
|
43
|
+
raise "Could not create areas"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
## Authentasaurus configuration
|
2
|
+
development: &non_production_settings
|
3
|
+
:mail:
|
4
|
+
:email: &development_email "foo_bar@your-domain.com"
|
5
|
+
:modules:
|
6
|
+
:remote:
|
7
|
+
:user:
|
8
|
+
:site: "http://localhost:3000/api_key/auth"
|
9
|
+
:session_element: "remote_sync"
|
10
|
+
:sync: true
|
11
|
+
:sync_to: "user"
|
12
|
+
:recoverable:
|
13
|
+
:token_expires_after: 10 # days
|
14
|
+
:send_email: true
|
15
|
+
:mail_subject: "Reset your password on your-domain.com"
|
16
|
+
:mail_from: *development_email
|
17
|
+
:invitable:
|
18
|
+
:send_email: true
|
19
|
+
:mail_subject: "You've been invited to your-domain.com"
|
20
|
+
:mail_from: *development_email
|
21
|
+
:validatable:
|
22
|
+
:send_email: true
|
23
|
+
:mail_subject: "Validate your account on your-domain.com"
|
24
|
+
:mail_from: *development_email
|
25
|
+
|
26
|
+
test:
|
27
|
+
<<: *non_production_settings
|
28
|
+
|
29
|
+
production:
|
30
|
+
:mail:
|
31
|
+
:email: &production_email "foo_bar@your-domain.com"
|
32
|
+
:modules:
|
33
|
+
:remote:
|
34
|
+
:user:
|
35
|
+
:site: "http://localhost:3000/api_key/auth"
|
36
|
+
:session_element: "remote_sync"
|
37
|
+
:sync: true
|
38
|
+
:sync_to: "user"
|
39
|
+
:recoverable:
|
40
|
+
:token_expires_after: 10 # days
|
41
|
+
:send_email: true
|
42
|
+
:mail_subject: "Reset your password on your-domain.com"
|
43
|
+
:mail_from: *production_email
|
44
|
+
:invitable:
|
45
|
+
:send_email: true
|
46
|
+
:mail_subject: "You've been invited to your-domain.com"
|
47
|
+
:mail_from: *production_email
|
48
|
+
:validatable:
|
49
|
+
:send_email: true
|
50
|
+
:mail_subject: "Validate your account on your-domain.com"
|
51
|
+
:mail_from: *production_email
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Description:
|
2
|
+
Generates a stub for Authentasaurus restful authentication views.
|
3
|
+
|
4
|
+
Examples:
|
5
|
+
`./script/generate authentasaurus_views users`
|
6
|
+
|
7
|
+
creates views for Authentasaurus with main user model named "user"
|
8
|
+
|
9
|
+
`./script/generate authentasaurus_views users --authorizable --validatable
|
10
|
+
|
11
|
+
creates views for Authentasaurus with main user model named "user" and also creates views
|
12
|
+
for authorization (--authorizable) and validation (--validatable)
|
@@ -0,0 +1,87 @@
|
|
1
|
+
class AuthentasaurusViewsGenerator < Rails::Generator::NamedBase
|
2
|
+
default_options :authorizable => false, :validatable => false, :invitable => false
|
3
|
+
|
4
|
+
def manifest
|
5
|
+
record do |m|
|
6
|
+
# Controller, View , Model, test, and fixture directories.
|
7
|
+
m.directory File.join('app/views', class_path)
|
8
|
+
# Other directories
|
9
|
+
m.directory File.join('app/views', class_path, "sessions")
|
10
|
+
m.directory File.join('app/views', class_path, file_name)
|
11
|
+
m.directory File.join('app/views', class_path, "authentasaurus_emailer")
|
12
|
+
m.directory File.join('app/views', class_path, "recoveries")
|
13
|
+
|
14
|
+
# Views
|
15
|
+
## user sessions
|
16
|
+
m.file 'views/sessions/new.html.erb', File.join("app/views", class_path, "sessions", "new.html.erb")
|
17
|
+
m.file 'views/sessions/no_access.html.erb', File.join("app/views", class_path, "sessions", "no_access.html.erb")
|
18
|
+
## users
|
19
|
+
m.file 'views/users/edit.html.erb', File.join("app/views", class_path, file_name, "edit.html.erb")
|
20
|
+
m.file 'views/users/index.html.erb', File.join("app/views", class_path, file_name, "index.html.erb")
|
21
|
+
m.file 'views/users/new.html.erb', File.join("app/views", class_path, file_name, "new.html.erb")
|
22
|
+
m.file 'views/users/show.html.erb', File.join("app/views", class_path, file_name, "show.html.erb")
|
23
|
+
## recoverable
|
24
|
+
m.file 'views/recoveries/new.html.erb', File.join("app/views", class_path, "recoveries", "new.html.erb")
|
25
|
+
m.file 'views/recoveries/edit.html.erb', File.join("app/views", class_path, "recoveries", "edit.html.erb")
|
26
|
+
|
27
|
+
|
28
|
+
if options[:authorizable]
|
29
|
+
m.directory File.join('app/views', class_path, "groups")
|
30
|
+
m.directory File.join('app/views', class_path, "areas")
|
31
|
+
m.directory File.join('app/views', class_path, "permissions")
|
32
|
+
## groups
|
33
|
+
m.file 'views/groups/show.html.erb', File.join('app/views', class_path, "groups", "show.html.erb")
|
34
|
+
m.file 'views/groups/index.html.erb', File.join("app/views", class_path, "groups", "index.html.erb")
|
35
|
+
m.file 'views/groups/edit.html.erb', File.join("app/views", class_path, "groups", "edit.html.erb")
|
36
|
+
m.file 'views/groups/new.html.erb', File.join("app/views", class_path, "groups", "new.html.erb")
|
37
|
+
## areas
|
38
|
+
m.file 'views/areas/edit.html.erb', File.join("app/views", class_path, "areas", "edit.html.erb")
|
39
|
+
m.file 'views/areas/index.html.erb', File.join("app/views", class_path, "areas", "index.html.erb")
|
40
|
+
m.file 'views/areas/new.html.erb', File.join("app/views", class_path, "areas", "new.html.erb")
|
41
|
+
m.file 'views/areas/show.html.erb', File.join("app/views", class_path, "areas", "show.html.erb")
|
42
|
+
## permissions
|
43
|
+
m.file 'views/permissions/edit.html.erb', File.join("app/views", class_path, "permissions", "edit.html.erb")
|
44
|
+
m.file 'views/permissions/index.html.erb', File.join("app/views", class_path, "permissions", "index.html.erb")
|
45
|
+
m.file 'views/permissions/new.html.erb', File.join("app/views", class_path, "permissions", "new.html.erb")
|
46
|
+
m.file 'views/permissions/show.html.erb', File.join("app/views", class_path, "permissions", "show.html.erb")
|
47
|
+
end
|
48
|
+
|
49
|
+
# Validations
|
50
|
+
if options[:validatable]
|
51
|
+
m.directory File.join('app/views', class_path, "validations")
|
52
|
+
|
53
|
+
# Views
|
54
|
+
m.file 'views/validations/activate.html.erb', File.join("app/views", class_path, "validations", "activate.html.erb")
|
55
|
+
m.file 'views/validations/resend_validation_email.html.erb', File.join("app/views", class_path, "validations", "resend_validation_email.html.erb")
|
56
|
+
m.file 'views/authentasaurus_emailer/validation_mail.html.erb', File.join("app/views", class_path, "authentasaurus_emailer", "validation_mail.html.erb")
|
57
|
+
end
|
58
|
+
|
59
|
+
# User invitations
|
60
|
+
if options[:invitable]
|
61
|
+
m.directory File.join('app/views', class_path, "user_invitations")
|
62
|
+
|
63
|
+
#Views
|
64
|
+
m.file 'views/user_invitations/index.html.erb', File.join('app/views', class_path, 'user_invitations', "index.html.erb")
|
65
|
+
m.file 'views/user_invitations/new.html.erb', File.join('app/views', class_path, 'user_invitations', "new.html.erb")
|
66
|
+
|
67
|
+
m.file 'views/authentasaurus_emailer/invitation_mail.html.erb', File.join("app/views", class_path, "authentasaurus_emailer", "invitation_mail.html.erb")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
protected
|
73
|
+
def banner
|
74
|
+
"Usage: #{$0} #{spec.name} MainUserControllerName"
|
75
|
+
end
|
76
|
+
|
77
|
+
def add_options!(opt)
|
78
|
+
opt.separator ''
|
79
|
+
opt.separator 'Options:'
|
80
|
+
opt.on("--validatable",
|
81
|
+
"Add validation to authentasaurus") { |v| options[:validatable] = v }
|
82
|
+
opt.on("--authorizable",
|
83
|
+
"Add authorization to authentasaurus") { |v| options[:authorizable] = v }
|
84
|
+
opt.on("--invitable",
|
85
|
+
"Add invitations to authentasaurus") { |v| options[:invitable] = v }
|
86
|
+
end
|
87
|
+
end
|