Class: Oxen::UsersController

Inherits:
AbstractResourcesController
  • Object
show all
Defined in:
app/controllers/oxen/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#confirmObject



6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/oxen/users_controller.rb', line 6

def confirm
  authorize resource
  if resource.confirm
    flash[:info] = t('user.confirmed_ok')
    render :confirm, layout: false, status: 200 and return
  else
    flash[:info] = t('user.not_confirmed_ok')
    render :confirm, layout: false, status: 401 and return
  end
end

#updateObject

def index

@users = User.all
authorize User

end def index

@resources = policy_scope(User)
authorize User

end

def show

@user = User.find(params[:id])
authorize @user

end

def update

@user = User.find(params[:id])
authorize @user
if @user.update_attributes(secure_params)
  redirect_to users_path, :notice => "User updated."
else
  redirect_to users_path, :alert => "Unable to update user."
end

end

def destroy

user = User.find(params[:id])
authorize user
user.destroy
redirect_to users_path, :notice => "User deleted."

end



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/controllers/oxen/users_controller.rb', line 47

def update
  if params[:user][:password].blank? && params[:user][:password].blank?
    params[:user].delete :password
    params[:user].delete :password_confirmation
  end
  authorize resource
  resource.max_role = current_user.role
  if resource.update_attributes(secure_params)
    redirect_to users_path, :notice => "User updated."
  else
    render :edit, :alert => "Unable to update user."
  end

  # super
end