Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge last little bits to devise.

  • Loading branch information...
commit 2d65e3f955a68c1ae45a79885498f538889fc09a 1 parent 1098f9f
@parndt parndt authored
View
63 authentication/app/controllers/admin/users_controller.rb
@@ -1,12 +1,10 @@
module Admin
class UsersController < Admin::BaseController
- crudify :user, :order => 'username ASC', :title_attribute => 'username'
+ crudify :user, :order => 'username ASC', :title_attribute => 'username'
before_filter :load_available_plugins_and_roles, :only => [:new, :create, :edit, :update]
- layout 'admin'
-
def index
search_all_users if searching?
paginate_all_users
@@ -34,15 +32,15 @@ def create
@user.roles = @selected_role_names.collect{|r| Role[r.downcase.to_sym]}
end
- redirect_to(admin_users_url, :notice => t('refinery.crudify.created', :what => @user.login))
+ redirect_to(admin_users_url, :notice => t('created', :what => @user.username, :scope => 'refinery.crudify'))
else
render :action => 'new'
end
end
- redirect_to(admin_users_url, :notice => t('refinery.crudify.created', :what => @user.username))
- else
- render :action => 'new'
+ def edit
+ @user = User.find params[:id]
+ @selected_plugin_names = @user.plugins.collect{|p| p.name}
end
def update
@@ -53,35 +51,28 @@ def update
end
@selected_plugin_names = params[:user][:plugins]
- def update
- # Store what the user selected.
- @selected_role_names = params[:user].delete(:roles) || []
- unless current_user.has_role?(:superuser) and RefinerySetting.find_or_set(:superuser_can_assign_roles, false)
- @selected_role_names = @user.roles.collect{|r| r.title}
- end
- @selected_plugin_names = params[:user][:plugins]
-
- # Prevent the current user from locking themselves out of the User manager
- if current_user.id == @user.id and (params[:user][:plugins].exclude?("refinery_users") || @selected_role_names.map(&:downcase).exclude?("refinery"))
- flash.now[:error] = t('admin.users.update.cannot_remove_user_plugin_from_current_user')
- render :action => "edit"
- else
- # Store the current plugins and roles for this user.
- @previously_selected_plugin_names = @user.plugins.collect{|p| p.name}
- @previously_selected_roles = @user.roles
- @user.roles = @selected_role_names.collect{|r| Role[r.downcase.to_sym]}
- if params[:user][:password].blank? and params[:user][:password_confirmation].blank?
- params[:user].delete(:password)
- params[:user].delete(:password_confirmation)
- end
-
- if @user.update_attributes(params[:user])
- redirect_to admin_users_url, :notice => t('refinery.crudify.updated', :what => @user.username)
+ # Prevent the current user from locking themselves out of the User manager
+ if current_user.id == @user.id and (params[:user][:plugins].exclude?("refinery_users") || @selected_role_names.map(&:downcase).exclude?("refinery"))
+ flash.now[:error] = t('cannot_remove_user_plugin_from_current_user', :scope => 'admin.users.update')
+ render :action => "edit"
else
- @user.plugins = @previously_selected_plugin_names
- @user.roles = @previously_selected_roles
- @user.save
- render :action => 'edit'
+ # Store the current plugins and roles for this user.
+ @previously_selected_plugin_names = @user.plugins.collect{|p| p.name}
+ @previously_selected_roles = @user.roles
+ @user.roles = @selected_role_names.collect{|r| Role[r.downcase.to_sym]}
+ if params[:user][:password].blank? and params[:user][:password_confirmation].blank?
+ params[:user].delete(:password)
+ params[:user].delete(:password_confirmation)
+ end
+
+ if @user.update_attributes(params[:user])
+ redirect_to admin_users_url, :notice => t('updated', :what => @user.username, :scope => 'refinery.crudify')
+ else
+ @user.plugins = @previously_selected_plugin_names
+ @user.roles = @previously_selected_roles
+ @user.save
+ render :action => 'edit'
+ end
end
end
@@ -96,4 +87,4 @@ def load_available_plugins_and_roles
end
end
-end
+end
View
1  changelog.md
@@ -36,6 +36,7 @@
* Applied HTML5 history pagination to all core engines. [Philip Arndt](https://github.com/parndt)
* Converted translate calls to use ``:scope``. [Uģis Ozols](https://github.com/ugisozols)
* Fixed issues where errors would only show up in English for some models and updated Russian translations. [Semyon Perepelitsa](https://github.com/semaperepelitsa)
+* Converted to devise for authentication, requiring password resets. [Philip Arndt](https://github.com/parndt) and [Uģis Ozols](https://github.com/ugisozols)
* [See full list](https://github.com/resolve/refinerycms/compare/0.9.8.9...0.9.9)
## 0.9.8.9 [21 December 2010]
Please sign in to comment.
Something went wrong with that request. Please try again.