From 723c6aaafc954b3a10bd7565a310f5ecf25ef20b Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Thu, 24 Jul 2014 22:13:18 +0300 Subject: [PATCH] check authorization --- app/views/admin/users/index.html.haml | 8 +++----- app/views/admin/users/show.html.haml | 3 +++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/views/admin/users/index.html.haml b/app/views/admin/users/index.html.haml index f8cabef6..65ec886e 100644 --- a/app/views/admin/users/index.html.haml +++ b/app/views/admin/users/index.html.haml @@ -52,11 +52,9 @@ %td = link_to "Edit", edit_admin_user_path(user), class: 'btn btn-primary' - if can? :destroy, user - %td - - if current_user.id == user.id or user.role_ids.include? 3 - =link_to 'Delete',admin_user_path(user), :method => :delete , :data => {:confirm => 'Are you sure ?'}, :disabled => true,:class => "btn btn-primary disabled btn-danger",:role => "button" - - else - =link_to 'Delete',admin_user_path(user), :method=> :delete , :data=> {:confirm => 'Are you sure ?'},:class => "btn btn-primary btn-danger" + %td= link_to 'Delete',admin_user_path(user), :method=> :delete , :data=> {:confirm => 'Are you sure ?'},:class => "btn btn-primary btn-danger" + - else + %td= link_to 'Delete',admin_user_path(user), :method => :delete , :data => {:confirm => 'Are you sure ?'}, :disabled => true,:class => "btn btn-primary disabled btn-danger",:role => "button" :javascript diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml index 56aaa5a7..9ad4c8ab 100644 --- a/app/views/admin/users/show.html.haml +++ b/app/views/admin/users/show.html.haml @@ -1,3 +1,6 @@ +- if can? :update, @user + .pull-right + = link_to "Edit", edit_admin_user_path(@user), class: 'btn btn-primary' %table.table - @show_attributes.each do |attr| %tr