ExtJS 4申请登录&认证与权 [英] ExtJS 4 Application Login & Authentification & Rights

查看:150
本文介绍了ExtJS 4申请登录&认证与权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用新推荐的应用程序结构在Ext JS 4上开发一个Web应用程序。所以我需要实施一个认证&权利制度。这个想法到目前为止:


  1. 服务器负责确保用户角色和权限。

  2. ExtJS前端必须根据权限和角色进行更改

  3. 我使用卡布局。第一个选项卡是登录屏幕,第二个应用程序

  4. 在我的控制器中,我检查用户是否登录。如果他有一个有效的身份,我切换到选项卡2.如果不是他现在我的问题是我不确定第2部分和第4部分?你如何实现这两个?

    解决方案


    • 一旦用户通过身份验证,服务器进入商店。例如: Ext.StoreManager.get('ConfigOptionStore')。loadData(/ * config data from server * /);

    • 使用 beforeRender 事件将组件添加到当前视图(在控制器中执行此操作),如下所示:



      pre> init:function(){
      this.control({
      'myPanel':{
      beforerender:function(cmp,eOpts)
      //将商店放在一个var中以方便访问
      var myConfigStore = Ext.StoreManager.get('ActiveUserStore')。getAt(0);

      //从这里你可以使用add()来添加如下所示的东西:
      if(myConfigStore.get('hasMyButton')){
      cmp.add({
      xtype:'button',
      文本:'我的按钮',
      动作:'doSomething'
      });
      }
      // etc ...
      }
      }) ;
      }


    • 确保在任何给定的时间更新第一条记录的当前配置选项(当您 loadData ,只加载一个记录)。


    • 这应该让你从正确的方向开始。只需确保使用最基本的组件创建初始视图,然后根据用户的配置添加自定义组件。



    I'm developing an web application on Ext JS 4 using the new recommended application structure. Therefore I need to implement a authentification & rights system. The idea so far:

    1. The server is responsible to ensure the user role and rights.
    2. ExtJS frontend has to change according to the permissions and role
    3. I use a card layout. The first tab is the login screen, the second the application
    4. In my controller I check if the user is logged in. If he has a valid identity I switch to tab 2. If not he is thrown back to tab 1.

    My problem now is that I'm unsure about part 2 and part 4? How would you implement these two?

    解决方案

    • Once the user is authenticated bring the config options over from the server into a store. For example: Ext.StoreManager.get('ConfigOptionStore').loadData(/* config data returned from server */);
    • Use the beforeRender event to add components to your current view (do this in the controller), like so:

      init: function() {
          this.control({
              'myPanel': {
                  beforerender: function(cmp, eOpts){
                  //place the store in a var for easy access
                  var myConfigStore = Ext.StoreManager.get('ActiveUserStore').getAt(0);
      
                  //from here you can use add() to add stuff like so:
                  if (myConfigStore.get('hasMyButton')) {
                      cmp.add({
                          xtype: 'button',
                          text: 'My Button',
                          action: 'doSomething'
                      });
                   }
                   //etc...
               }
           });
      }
      

    • Make sure that at any given time, you update the first record of the store with the current config options (when you loadData, load just one record).

    • This should get you started in the right direction. Just be sure to create your initial views with the only the most basic components, and then add the custom components based on the user's config.

    这篇关于ExtJS 4申请登录&认证与权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆