refinerycms-authentication 1.0.11 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. data/app/controllers/refinery/admin/users_controller.rb +100 -0
  2. data/app/controllers/refinery/passwords_controller.rb +51 -0
  3. data/app/controllers/refinery/sessions_controller.rb +26 -0
  4. data/app/controllers/refinery/users_controller.rb +42 -0
  5. data/app/helpers/refinery/sessions_helper.rb +4 -0
  6. data/app/helpers/refinery/users_helper.rb +4 -0
  7. data/app/mailers/refinery/user_mailer.rb +22 -0
  8. data/app/models/refinery/role.rb +18 -0
  9. data/app/models/refinery/roles_users.rb +8 -0
  10. data/app/models/refinery/user.rb +94 -0
  11. data/app/models/refinery/user_plugin.rb +8 -0
  12. data/app/views/refinery/admin/users/_actions.html.erb +6 -0
  13. data/app/views/{admin → refinery/admin}/users/_form.html.erb +15 -19
  14. data/app/views/{admin → refinery/admin}/users/_records.html.erb +1 -1
  15. data/app/views/refinery/admin/users/_user.html.erb +21 -0
  16. data/app/views/refinery/admin/users/_users.html.erb +4 -0
  17. data/app/views/refinery/admin/users/edit.html.erb +1 -0
  18. data/app/views/refinery/admin/users/index.html.erb +6 -0
  19. data/app/views/refinery/admin/users/new.html.erb +1 -0
  20. data/app/views/{layouts → refinery/layouts}/login.html.erb +3 -4
  21. data/app/views/refinery/passwords/edit.html.erb +26 -0
  22. data/app/views/refinery/passwords/new.html.erb +17 -0
  23. data/app/views/{sessions → refinery/sessions}/new.html.erb +6 -8
  24. data/app/views/refinery/user_mailer/reset_notification.html.erb +12 -0
  25. data/app/views/refinery/user_mailer/reset_notification.text.plain.erb +7 -0
  26. data/app/views/refinery/users/new.html.erb +29 -0
  27. data/config/locales/bg.yml +55 -55
  28. data/config/locales/cs.yml +58 -58
  29. data/config/locales/da.yml +55 -55
  30. data/config/locales/de.yml +55 -55
  31. data/config/locales/el.yml +55 -55
  32. data/config/locales/en.yml +55 -55
  33. data/config/locales/es.yml +55 -60
  34. data/config/locales/fi.yml +55 -55
  35. data/config/locales/fr.yml +55 -55
  36. data/config/locales/it.yml +51 -57
  37. data/config/locales/ja.yml +72 -0
  38. data/config/locales/ko.yml +72 -0
  39. data/config/locales/lt.yml +46 -46
  40. data/config/locales/lv.yml +55 -55
  41. data/config/locales/nb.yml +55 -55
  42. data/config/locales/nl.yml +55 -55
  43. data/config/locales/pl.yml +53 -59
  44. data/config/locales/pt-BR.yml +52 -52
  45. data/config/locales/rs.yml +62 -61
  46. data/config/locales/ru.yml +52 -52
  47. data/config/locales/sk.yml +55 -55
  48. data/config/locales/sl.yml +55 -54
  49. data/config/locales/sv.yml +52 -52
  50. data/config/locales/vi.yml +55 -55
  51. data/config/locales/zh-CN.yml +55 -55
  52. data/config/locales/zh-TW.yml +55 -55
  53. data/config/routes.rb +30 -24
  54. data/db/migrate/20100913234705_create_refinerycms_authentication_schema.rb +30 -30
  55. data/lib/refinery/authenticated_system.rb +40 -0
  56. data/lib/refinery/authentication/configuration.rb +9 -0
  57. data/lib/refinery/authentication/engine.rb +36 -0
  58. data/lib/refinery/authentication.rb +29 -0
  59. data/lib/refinerycms-authentication.rb +1 -54
  60. data/refinerycms-authentication.gemspec +14 -109
  61. data/spec/controllers/refinery/admin/users_controller_spec.rb +73 -0
  62. data/spec/factories/user.rb +38 -0
  63. data/spec/models/refinery/user_spec.rb +220 -0
  64. data/spec/requests/refinery/admin/users_spec.rb +49 -0
  65. data/spec/requests/refinery/passwords_spec.rb +84 -0
  66. data/spec/requests/refinery/sessions_spec.rb +62 -0
  67. metadata +109 -124
  68. data/app/controllers/admin/users_controller.rb +0 -86
  69. data/app/controllers/passwords_controller.rb +0 -42
  70. data/app/controllers/sessions_controller.rb +0 -23
  71. data/app/controllers/users_controller.rb +0 -67
  72. data/app/helpers/sessions_helper.rb +0 -2
  73. data/app/helpers/users_helper.rb +0 -2
  74. data/app/mailers/user_mailer.rb +0 -20
  75. data/app/models/role.rb +0 -16
  76. data/app/models/roles_users.rb +0 -6
  77. data/app/models/user.rb +0 -65
  78. data/app/models/user_plugin.rb +0 -6
  79. data/app/views/admin/users/_actions.html.erb +0 -5
  80. data/app/views/admin/users/_user.html.erb +0 -19
  81. data/app/views/admin/users/_users.html.erb +0 -4
  82. data/app/views/admin/users/edit.html.erb +0 -1
  83. data/app/views/admin/users/index.html.erb +0 -6
  84. data/app/views/admin/users/new.html.erb +0 -1
  85. data/app/views/passwords/edit.html.erb +0 -31
  86. data/app/views/passwords/new.html.erb +0 -18
  87. data/app/views/user_mailer/reset_notification.html.erb +0 -12
  88. data/app/views/user_mailer/reset_notification.text.plain.erb +0 -7
  89. data/app/views/users/new.html.erb +0 -41
  90. data/config/locales/jp.yml +0 -72
  91. data/config/locales/lolcat.yml +0 -55
  92. data/db/migrate/20100929035252_add_missing_indexes_to_roles_users.rb +0 -11
  93. data/db/migrate/20101206013505_change_to_devise_users_table.rb +0 -27
  94. data/db/migrate/20110106184757_add_remember_created_at_to_users.rb +0 -9
  95. data/db/migrate/20110325213325_remove_password_salt_from_users.rb +0 -13
  96. data/features/lost_password.feature +0 -49
  97. data/features/manage_users.feature +0 -88
  98. data/features/step_definitions/lost_password.rb +0 -8
  99. data/features/step_definitions/user_steps.rb +0 -41
  100. data/features/support/factories.rb +0 -32
  101. data/features/support/paths.rb +0 -24
  102. data/lib/authenticated_system.rb +0 -29
  103. data/lib/gemspec.rb +0 -38
  104. data/lib/generators/refinerycms_authentication_generator.rb +0 -8
  105. data/spec/models/user_spec.rb +0 -152
@@ -0,0 +1,100 @@
1
+ module Refinery
2
+ module Admin
3
+ class UsersController < Refinery::AdminController
4
+
5
+ crudify :'refinery/user',
6
+ :order => 'username ASC',
7
+ :title_attribute => 'username',
8
+ :xhr_paging => true
9
+
10
+ before_filter :load_available_plugins_and_roles, :only => [:new, :create, :edit, :update]
11
+
12
+ def new
13
+ @user = Refinery::User.new
14
+ @selected_plugin_names = []
15
+ end
16
+
17
+ def create
18
+ @user = Refinery::User.new(params[:user])
19
+ @selected_plugin_names = params[:user][:plugins] || []
20
+ @selected_role_names = params[:user][:roles] || []
21
+
22
+ if @user.save
23
+ @user.plugins = @selected_plugin_names
24
+ # if the user is a superuser and can assign roles according to this site's
25
+ # settings then the roles are set with the POST data.
26
+ unless current_refinery_user.has_role?(:superuser) and Refinery::Authentication.superuser_can_assign_roles
27
+ @user.add_role(:refinery)
28
+ else
29
+ @user.roles = @selected_role_names.collect { |r| Refinery::Role[r.downcase.to_sym] }
30
+ end
31
+
32
+ redirect_to refinery.admin_users_path,
33
+ :notice => t('created', :what => @user.username, :scope => 'refinery.crudify')
34
+ else
35
+ render :action => 'new'
36
+ end
37
+ end
38
+
39
+ def edit
40
+ @user = Refinery::User.find(params[:id])
41
+
42
+ redirect_unless_user_editable!
43
+
44
+ @selected_plugin_names = @user.plugins.collect(&:name)
45
+ end
46
+
47
+ def update
48
+ redirect_unless_user_editable!
49
+
50
+ # Store what the user selected.
51
+ @selected_role_names = params[:user].delete(:roles) || []
52
+ unless current_refinery_user.has_role?(:superuser) and Refinery::Authentication.superuser_can_assign_roles
53
+ @selected_role_names = @user.roles.collect(&:title)
54
+ end
55
+ @selected_plugin_names = params[:user][:plugins]
56
+
57
+ # Prevent the current user from locking themselves out of the User manager
58
+ if current_refinery_user.id == @user.id and (params[:user][:plugins].exclude?("refinery_users") || @selected_role_names.map(&:downcase).exclude?("refinery"))
59
+ flash.now[:error] = t('cannot_remove_user_plugin_from_current_user', :scope => 'refinery.admin.users.update')
60
+ render :edit
61
+ else
62
+ # Store the current plugins and roles for this user.
63
+ @previously_selected_plugin_names = @user.plugins.collect(&:name)
64
+ @previously_selected_roles = @user.roles
65
+ @user.roles = @selected_role_names.collect { |r| Refinery::Role[r.downcase.to_sym] }
66
+ if params[:user][:password].blank? and params[:user][:password_confirmation].blank?
67
+ params[:user].except!(:password, :password_confirmation)
68
+ end
69
+
70
+ if @user.update_attributes(params[:user])
71
+ redirect_to refinery.admin_users_path,
72
+ :notice => t('updated', :what => @user.username, :scope => 'refinery.crudify')
73
+ else
74
+ @user.plugins = @previously_selected_plugin_names
75
+ @user.roles = @previously_selected_roles
76
+ @user.save
77
+ render :edit
78
+ end
79
+ end
80
+ end
81
+
82
+ protected
83
+
84
+ def load_available_plugins_and_roles
85
+ @available_plugins = Refinery::Plugins.registered.in_menu.collect { |a|
86
+ { :name => a.name, :title => a.title }
87
+ }.sort_by { |a| a[:title] }
88
+
89
+ @available_roles = Refinery::Role.all
90
+ end
91
+
92
+ def redirect_unless_user_editable!
93
+ unless current_refinery_user.can_edit?(@user)
94
+ redirect_to(main_app.refinery_admin_users_path) and return
95
+ end
96
+ end
97
+
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,51 @@
1
+ module Refinery
2
+ class PasswordsController < Devise::PasswordsController
3
+ layout 'refinery/layouts/login'
4
+
5
+ before_filter :store_password_reset_return_to, :only => [:update]
6
+ def store_password_reset_return_to
7
+ session[:'refinery_user_return_to'] = refinery.admin_root_path
8
+ end
9
+ protected :store_password_reset_return_to
10
+
11
+ # Rather than overriding devise, it seems better to just apply the notice here.
12
+ after_filter :give_notice, :only => [:update]
13
+ def give_notice
14
+ if %w(notice error alert).exclude?(flash.keys.map(&:to_s)) or @refinery_user.errors.any?
15
+ flash[:notice] = t('successful', :scope => 'refinery.users.reset', :email => @refinery_user.email)
16
+ end
17
+ end
18
+ protected :give_notice
19
+
20
+ # GET /registrations/password/edit?reset_password_token=abcdef
21
+ def edit
22
+ if params[:reset_password_token] and (@refinery_user = User.where(:reset_password_token => params[:reset_password_token]).first).present?
23
+ respond_with(@refinery_user)
24
+ else
25
+ redirect_to refinery.new_refinery_user_password_path,
26
+ :flash => ({ :error => t('code_invalid', :scope => 'refinery.users.reset') })
27
+ end
28
+ end
29
+
30
+ # POST /registrations/password
31
+ def create
32
+ if params[:refinery_user].present? and (email = params[:refinery_user][:email]).present? and
33
+ (user = User.where(:email => email).first).present?
34
+
35
+ # Call devise reset function.
36
+ user.send(:generate_reset_password_token!)
37
+ UserMailer.reset_notification(user, request).deliver
38
+ redirect_to refinery.new_refinery_user_session_path,
39
+ :notice => t('email_reset_sent', :scope => 'refinery.users.forgot')
40
+ else
41
+ @refinery_user = User.new(params[:refinery_user])
42
+ flash.now[:error] = if @refinery_user.email.blank?
43
+ t('blank_email', :scope => 'refinery.users.forgot')
44
+ else
45
+ t('email_not_associated_with_account_html', :email => @refinery_user.email, :scope => 'refinery.users.forgot').html_safe
46
+ end
47
+ render :new
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,26 @@
1
+ module Refinery
2
+ class SessionsController < Devise::SessionsController
3
+ layout 'refinery/layouts/login'
4
+
5
+ before_filter :clear_unauthenticated_flash, :only => [:new]
6
+
7
+ def create
8
+ super
9
+ rescue ::BCrypt::Errors::InvalidSalt, ::BCrypt::Errors::InvalidHash
10
+ flash[:error] = t('password_encryption', :scope => 'refinery.users.forgot')
11
+ redirect_to refinery.new_refinery_user_password_path
12
+ end
13
+
14
+ protected
15
+
16
+ # We don't like this alert.
17
+ def clear_unauthenticated_flash
18
+ if flash.keys.include?(:alert) and flash.any?{|k, v|
19
+ ['unauthenticated', t('unauthenticated', :scope => 'devise.failure')].include?(v)
20
+ }
21
+ flash.delete(:alert)
22
+ end
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,42 @@
1
+ module Refinery
2
+ class UsersController < Devise::RegistrationsController
3
+
4
+ # Protect these actions behind an admin login
5
+ before_filter :redirect?, :only => [:new, :create]
6
+
7
+ layout 'refinery/layouts/login'
8
+
9
+ def new
10
+ @user = User.new
11
+ end
12
+
13
+ # This method should only be used to create the first Refinery user.
14
+ def create
15
+ @user = User.new(params[:user])
16
+
17
+ if @user.create_first
18
+ flash[:message] = "<h2>#{t('welcome', :scope => 'refinery.users.create', :who => @user.username).gsub(/\.$/, '')}.</h2>".html_safe
19
+
20
+ sign_in(@user)
21
+ redirect_back_or_default(refinery.admin_root_path)
22
+ else
23
+ render :new
24
+ end
25
+ end
26
+
27
+ protected
28
+
29
+ def redirect?
30
+ if refinery_user?
31
+ redirect_to refinery.admin_users_path
32
+ elsif refinery_users_exist?
33
+ redirect_to refinery.new_refinery_user_session_path
34
+ end
35
+ end
36
+
37
+ def refinery_users_exist?
38
+ Refinery::Role[:refinery].users.any?
39
+ end
40
+
41
+ end
42
+ end
@@ -0,0 +1,4 @@
1
+ module Refinery
2
+ module SessionsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Refinery
2
+ module UsersHelper
3
+ end
4
+ end
@@ -0,0 +1,22 @@
1
+ module Refinery
2
+ class UserMailer < ActionMailer::Base
3
+
4
+ def reset_notification(user, request)
5
+ @user = user
6
+ @url = refinery.edit_refinery_user_password_url({
7
+ :host => request.host_with_port,
8
+ :reset_password_token => @user.reset_password_token
9
+ })
10
+
11
+ mail(:to => user.email,
12
+ :subject => t('subject', :scope => 'refinery.user_mailer.reset_notification'),
13
+ :from => "\"#{Refinery::Core.site_name}\" <no-reply@#{request.domain}>")
14
+ end
15
+
16
+ protected
17
+
18
+ def url_prefix(request)
19
+ "#{request.protocol}#{request.host_with_port}"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,18 @@
1
+ module Refinery
2
+ class Role < Refinery::Core::BaseModel
3
+
4
+ has_and_belongs_to_many :users, :join_table => :refinery_roles_users
5
+
6
+ before_validation :camelize_title
7
+ validates :title, :uniqueness => true
8
+
9
+ def camelize_title(role_title = self.title)
10
+ self.title = role_title.to_s.camelize
11
+ end
12
+
13
+ def self.[](title)
14
+ find_or_create_by_title(title.to_s.camelize)
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ module Refinery
2
+ class RolesUsers < Refinery::Core::BaseModel
3
+
4
+ belongs_to :role
5
+ belongs_to :user
6
+
7
+ end
8
+ end
@@ -0,0 +1,94 @@
1
+ require 'devise'
2
+
3
+ module Refinery
4
+ class User < Refinery::Core::BaseModel
5
+ extend FriendlyId
6
+
7
+ has_and_belongs_to_many :roles, :join_table => :refinery_roles_users
8
+
9
+ has_many :plugins, :class_name => "UserPlugin", :order => "position ASC", :dependent => :destroy
10
+ friendly_id :username
11
+
12
+ # Include default devise modules. Others available are:
13
+ # :token_authenticatable, :confirmable, :lockable and :timeoutable
14
+ if self.respond_to?(:devise)
15
+ devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :authentication_keys => [:login]
16
+ end
17
+
18
+ # Setup accessible (or protected) attributes for your model
19
+ # :login is a virtual attribute for authenticating by either username or email
20
+ # This is in addition to a real persisted field like 'username'
21
+ attr_accessor :login
22
+ attr_accessible :email, :password, :password_confirmation, :remember_me, :username, :plugins, :login
23
+
24
+ validates :username, :presence => true, :uniqueness => true
25
+
26
+ class << self
27
+ # Find user by email or username.
28
+ # https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-sign_in-using-their-username-or-email-address
29
+ def find_for_database_authentication(conditions)
30
+ value = conditions[authentication_keys.first]
31
+ where(["username = :value OR email = :value", { :value => value }]).first
32
+ end
33
+ end
34
+
35
+ def plugins=(plugin_names)
36
+ if persisted? # don't add plugins when the user_id is nil.
37
+ UserPlugin.delete_all(:user_id => id)
38
+
39
+ plugin_names.each_with_index do |plugin_name, index|
40
+ plugins.create(:name => plugin_name, :position => index) if plugin_name.is_a?(String)
41
+ end
42
+ end
43
+ end
44
+
45
+ def authorized_plugins
46
+ plugins.collect { |p| p.name } | ::Refinery::Plugins.always_allowed.names
47
+ end
48
+
49
+ def can_delete?(user_to_delete = self)
50
+ user_to_delete.persisted? &&
51
+ !user_to_delete.has_role?(:superuser) &&
52
+ ::Refinery::Role[:refinery].users.any? &&
53
+ id != user_to_delete.id
54
+ end
55
+
56
+ def can_edit?(user_to_edit = self)
57
+ user_to_edit.persisted? && (
58
+ user_to_edit == self ||
59
+ self.has_role?(:superuser)
60
+ )
61
+ end
62
+
63
+ def add_role(title)
64
+ raise ArgumentException, "Role should be the title of the role not a role object." if title.is_a?(::Refinery::Role)
65
+ roles << ::Refinery::Role[title] unless has_role?(title)
66
+ end
67
+
68
+ def has_role?(title)
69
+ raise ArgumentException, "Role should be the title of the role not a role object." if title.is_a?(::Refinery::Role)
70
+ roles.any?{|r| r.title == title.to_s.camelize}
71
+ end
72
+
73
+ def create_first
74
+ if valid?
75
+ # first we need to save user
76
+ save
77
+ # add refinery role
78
+ add_role(:refinery)
79
+ # add superuser role
80
+ add_role(:superuser) if ::Refinery::Role[:refinery].users.count == 1
81
+ # add plugins
82
+ self.plugins = Refinery::Plugins.registered.in_menu.names
83
+ end
84
+
85
+ # return true/false based on validations
86
+ valid?
87
+ end
88
+
89
+ def to_s
90
+ username
91
+ end
92
+
93
+ end
94
+ end
@@ -0,0 +1,8 @@
1
+ module Refinery
2
+ class UserPlugin < Refinery::Core::BaseModel
3
+
4
+ belongs_to :user
5
+ attr_accessible :user_id, :name, :position
6
+
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ <ul>
2
+ <li>
3
+ <%= link_to t('.create_new_user'),
4
+ refinery.new_admin_user_path, :class => "add_icon" %>
5
+ </li>
6
+ </ul>
@@ -1,10 +1,6 @@
1
- <%= form_for [:admin, @user] do |f| %>
1
+ <%= form_for [refinery, :admin, @user] do |f| %>
2
2
 
3
- <%= render :partial => "/shared/admin/error_messages",
4
- :locals => {
5
- :object => @user,
6
- :include_object_name => true
7
- } %>
3
+ <%= render '/refinery/admin/error_messages', :object => @user, :include_object_name => true %>
8
4
 
9
5
  <div class='field'>
10
6
  <%= f.label :username %>
@@ -17,7 +13,10 @@
17
13
  <div class='field'>
18
14
  <%= f.label :password %>
19
15
  <%= f.password_field :password, :autocomplete => 'off' %>
20
- <%= "<br /><span class='preview'>#{t('.blank_password_keeps_current')}</span>".html_safe if @user.persisted? %>
16
+ <% if @user.persisted? %>
17
+ <%= content_tag(:br) %>
18
+ <%= content_tag(:span, t('.blank_password_keeps_current')) %>
19
+ <% end %>
21
20
  </div>
22
21
  <div class='field'>
23
22
  <%= f.label :password_confirmation %>
@@ -31,7 +30,7 @@
31
30
  <ul id='plugins' class='checkboxes'>
32
31
  <% @available_plugins.each do |plugin| -%>
33
32
  <% if Refinery::Plugins.always_allowed.names.include?(plugin[:name]) or
34
- (plugin[:name] == 'refinery_users' and @user.id == current_user.id) %>
33
+ (plugin[:name] == 'refinery_users' and @user.id == current_refinery_user.id) %>
35
34
  <%= hidden_field_tag 'user[plugins][]', plugin[:name],
36
35
  :id => "plugins_#{plugin[:name]}" %>
37
36
  <% else %>
@@ -40,7 +39,7 @@
40
39
  @selected_plugin_names.include?(plugin[:name]),
41
40
  :id => "plugins_#{plugin[:name]}" %>
42
41
  <%= f.label 'user[plugins][]',
43
- t('title', :scope => "plugins.#{plugin[:name].downcase}", :default => plugin[:title]),
42
+ t('title', :scope => "refinery.plugins.#{plugin[:name].downcase}", :default => plugin[:title]),
44
43
  :class => "stripped",
45
44
  :for => "plugins_#{plugin[:name]}" %>
46
45
  </li>
@@ -49,7 +48,7 @@
49
48
  </ul>
50
49
  </div>
51
50
 
52
- <% if current_user.has_role?(:superuser) and RefinerySetting.find_or_set(:superuser_can_assign_roles, false) %>
51
+ <% if current_refinery_user.has_role?(:superuser) and Refinery::Authentication.superuser_can_assign_roles %>
53
52
  <div class='field role_access'>
54
53
  <span class='label_with_help'>
55
54
  <%= f.label :role_access, t('.role_access'), :class => "title_label" %>
@@ -61,7 +60,7 @@
61
60
  <%= check_box_tag 'user[roles][]', downcased_title, @user.has_role?(title),
62
61
  :id => "roles_#{downcased_title}" %>
63
62
  <%= f.label 'user[roles][]',
64
- t(downcased_title, :scope => 'roles', :default => title),
63
+ t(downcased_title, :scope => 'refinery.roles', :default => title),
65
64
  :class => 'stripped',
66
65
  :for => "roles_#{downcased_title}" %>
67
66
  </li>
@@ -70,14 +69,11 @@
70
69
  </div>
71
70
  <% end %>
72
71
 
73
- <%= render :partial => "/shared/admin/form_actions",
74
- :locals => {
75
- :f => f,
76
- :continue_editing => false,
77
- :hide_delete => !current_user.can_delete?(@user),
78
- :delete_title => t('delete', :scope => 'admin.users'),
79
- :delete_confirmation => t('message', :scope => 'shared.admin.delete', :title => @user.username)
80
- } %>
72
+ <%= render '/refinery/admin/form_actions', :f => f,
73
+ :continue_editing => false,
74
+ :hide_delete => !current_refinery_user.can_delete?(@user),
75
+ :delete_title => t('delete', :scope => 'refinery.admin.users'),
76
+ :delete_confirmation => t('message', :scope => 'refinery.admin.delete', :title => @user.username) %>
81
77
  <% end %>
82
78
 
83
79
  <% content_for :javascripts do %>
@@ -1,3 +1,3 @@
1
1
  <div class='pagination_container'>
2
- <%= render :partial => 'users' %>
2
+ <%= render 'users' %>
3
3
  </div>
@@ -0,0 +1,21 @@
1
+ <li id="sortable_<%= user.id %>" class='clearfix record <%= cycle("on", "on-hover") %>'>
2
+ <span class='title'>
3
+ <strong><%= user.username %></strong>
4
+ <span class="preview">
5
+ <%= t('.preview', :who => user.email, :created_at => l(user.created_at, :format => :short)) %>
6
+ </span>
7
+ </span>
8
+ <span class='actions'>
9
+ <%= mail_to user.email, refinery_icon_tag('email_go.png'),
10
+ :title => t('.email_user') %>
11
+ <%= link_to refinery_icon_tag('application_edit.png'),
12
+ refinery.edit_admin_user_path(user),
13
+ :title => t('edit', :scope => 'refinery.admin.users') if current_refinery_user.can_edit?(user) %>
14
+ <%= link_to refinery_icon_tag('delete.png'),
15
+ refinery.admin_user_path(user),
16
+ :class => "cancel confirm-delete",
17
+ :title => t('delete', :scope => 'refinery.admin.users'),
18
+ :method => :delete,
19
+ :confirm => t('message', :scope => 'refinery.admin.delete', :title => user.username) if current_refinery_user.can_delete?(user) %>
20
+ </span>
21
+ </li>
@@ -0,0 +1,4 @@
1
+ <%= will_paginate @users %>
2
+ <ul>
3
+ <%= render :partial => 'user', :collection => @users %>
4
+ </ul>
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -0,0 +1,6 @@
1
+ <section id='records'>
2
+ <%= render 'records' %>
3
+ </section>
4
+ <aside id='actions'>
5
+ <%= render 'actions' %>
6
+ </aside>
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -1,6 +1,6 @@
1
1
  <!DOCTYPE html>
2
- <%= render :partial => "/shared/html_tag" %>
3
- <%= render :partial => "/admin/head", :locals => {:login => true} %>
2
+ <%= render '/refinery/html_tag' %>
3
+ <%= render '/refinery/admin/head' %>
4
4
  <body class='login <%= I18n.locale %>'>
5
5
  <div id='tooltip_container'></div>
6
6
  <header>
@@ -10,12 +10,11 @@
10
10
  <div id="page">
11
11
  <div id="content" class="clearfix">
12
12
  <div id="flash_container">
13
- <%= render :partial => "/shared/message" %>
13
+ <%= render '/refinery/message' %>
14
14
  </div>
15
15
  <%= yield %>
16
16
  </div>
17
17
  </div>
18
18
  </div>
19
- <%= render :partial => "/admin/javascripts", :locals => {:login => true} %>
20
19
  </body>
21
20
  </html>
@@ -0,0 +1,26 @@
1
+ <% content_for :header, t('pick_new_password_for', :scope => 'refinery.users.reset', :email => @refinery_user.email) %>
2
+
3
+ <%= form_for resource, :as => resource_name,
4
+ :url => refinery.refinery_user_password_path,
5
+ :html => { :method => :put } do |f| %>
6
+ <%= f.hidden_field :reset_password_token %>
7
+
8
+ <%= render '/refinery/admin/error_messages', :object => @refinery_user, :include_object_name => true %>
9
+
10
+ <div class='field'>
11
+ <%= f.label :password %>
12
+ <%= f.password_field :password, :class => 'larger widest' %>
13
+ </div>
14
+
15
+ <div class='field'>
16
+ <%= f.label :password_confirmation %>
17
+ <%= f.password_field :password_confirmation, :class => 'larger widest' %>
18
+ </div>
19
+
20
+ <%= render '/refinery/admin/form_actions', :f => f,
21
+ :continue_editing => false,
22
+ :submit_button_text => t('reset_password', :scope => 'refinery.users.reset'),
23
+ :cancel_url => refinery.new_refinery_user_session_path,
24
+ :cancel_title => nil,
25
+ :hide_delete => true -%>
26
+ <% end -%>
@@ -0,0 +1,17 @@
1
+ <% content_for :header, t('enter_email_address', :scope => 'refinery.users.forgot') %>
2
+
3
+ <%= form_for resource, :as => resource_name,
4
+ :url => refinery.refinery_user_password_path,
5
+ :html => { :method => :post } do |f| %>
6
+
7
+ <div class='field'>
8
+ <%= f.text_field :email, :class => "larger widest",
9
+ :placeholder => t('email_address', :scope => 'refinery.users.forgot') %>
10
+ </div>
11
+
12
+ <%= render '/refinery/admin/form_actions', :f => f,
13
+ :continue_editing => false,
14
+ :submit_button_text => t('reset_password', :scope => 'refinery.users.forgot'),
15
+ :cancel_url => refinery.refinery_user_session_path,
16
+ :cancel_title => nil -%>
17
+ <% end -%>
@@ -1,6 +1,7 @@
1
1
  <% content_for :header, t('.hello_please_sign_in') %>
2
2
 
3
- <%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
3
+ <%= form_for resource, :as => resource_name,
4
+ :url => refinery.refinery_user_session_path do |f| %>
4
5
  <div class='field session_username clearfix'>
5
6
  <%= f.label :login %>
6
7
  <%= f.text_field :login, :class => 'larger widest' %>
@@ -17,13 +18,10 @@
17
18
  </div>
18
19
  <% end %>
19
20
  <div class='field forgot_password'>
20
- <%= link_to t('.forgot_password'), new_password_path(resource_name) %>
21
+ <%= link_to t('.forgot_password'), refinery.new_refinery_user_password_path %>
21
22
  </div>
22
23
  </div>
23
- <%= render :partial => "/shared/admin/form_actions",
24
- :locals => {
25
- :f => f,
26
- :submit_button_text => t('.sign_in'),
27
- :hide_cancel => true
28
- } %>
24
+ <%= render '/refinery/admin/form_actions', :f => f,
25
+ :submit_button_text => t('.sign_in'),
26
+ :hide_cancel => true %>
29
27
  <% end -%>
@@ -0,0 +1,12 @@
1
+ <p>
2
+ <%= t('reset_request_received_for', :scope => 'refinery.user_mailer.reset_notification', :username => @user.username) %>
3
+ </p>
4
+ <p>
5
+ <%= t('visit_this_url', :scope => 'refinery.user_mailer.reset_notification') %>:
6
+ </p>
7
+ <p>
8
+ <%= @url %>
9
+ </p>
10
+ <p>
11
+ (<%= t('remain_same_if_no_action', :scope => 'refinery.user_mailer.reset_notification') %>)
12
+ </p>
@@ -0,0 +1,7 @@
1
+ <%= t('reset_request_received_for', :scope => 'refinery.user_mailer.reset_notification', :username => @user.username) %>
2
+
3
+ <%= t('visit_this_url', :scope => 'refinery.user_mailer.reset_notification') %>:
4
+
5
+ <%= @url %>
6
+
7
+ (<%= t('remain_same_if_no_action', :scope => 'refinery.user_mailer.reset_notification') %>)