[Kimchi-devel] [PATCH V2 2/4] Authorization: remove host/template tabs for non-root users

Wen Wang wenwang at linux.vnet.ibm.com
Tue Jul 22 01:21:31 UTC 2014


On 07/22/2014 03:42 AM, Aline Manera wrote:
>
> On 07/21/2014 05:21 AM, wenwang at linux.vnet.ibm.com wrote:
>> From: Wen Wang <wenwang at linux.vnet.ibm.com>
>>
>> V1 -> V2:
>> read only "roles" from cookie instead of roles of each tab(Aline)
>>
>> This patch removed host/template tabs from non-root users
>>
>> Signed-off-by: Wen Wang <wenwang at linux.vnet.ibm.com>
>> ---
>>   ui/js/src/kimchi.main.js |   24 ++++++++++++++++--------
>>   1 files changed, 16 insertions(+), 8 deletions(-)
>>
>> diff --git a/ui/js/src/kimchi.main.js b/ui/js/src/kimchi.main.js
>> index 8eb4d73..9488299 100644
>> --- a/ui/js/src/kimchi.main.js
>> +++ b/ui/js/src/kimchi.main.js
>> @@ -23,13 +23,16 @@ kimchi.main = function() {
>>           $(tabs).each(function(i, tab) {
>>               var title = tab['title'];
>>               var path = tab['path'];
>> -            tabsHtml.push(
>> -                '<li>',
>> -                    '<a class="item" href="', path, '">',
>> -                        title,
>> -                    '</a>',
>> -                '</li>'
>> -            );
>> +            var mode = tab['mode'];
>> +            if (mode != 'none') {
>> +                tabsHtml.push(
>> +                    '<li>',
>> +                        '<a class="item" href="', path, '">',
>> +                            title,
>> +                        '</a>',
>> +                    '</li>'
>> +                );
>> +            }
>>           });
>>           return tabsHtml.join('');
>>       };
>> @@ -41,9 +44,14 @@ kimchi.main = function() {
>>               var titleKey = $tab.find('title').text();
>>               var title = i18n[titleKey] ? i18n[titleKey] : titleKey;
>>               var path = $tab.find('path').text();
>
>> +            var roles = kimchi.cookie.get('roles');
>> +            var roleString = 'JSON.parse(roles).' + 
>> titleKey.toLowerCase();
>> +            var role = eval(roleString);
>> +            var mode = $tab.find('[role="' + role + '"]').attr('mode');
>
> As you proposed in the previous patch set, you can store the role in a 
> cookie here to be used when needed.
ACK. As we discussed in the previous patch , it's "tabMode" that is 
going to be stored in
>
>>               tabs.push({
>>                   title: title,
>> -                path: path
>> +                path: path,
>> +                mode: mode
>>               });
>>           });
>>
>




More information about the Kimchi-devel mailing list