ExtJS 4 应用程序登录认证&权利 [英] ExtJS 4 Application Login & Authentification & Rights

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

问题描述

我正在使用新推荐的应用程序结构在 Ext JS 4 上开发 Web 应用程序.因此,我需要实施身份验证&权利制度.到目前为止的想法:

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. 服务器负责确保用户角色和权限.
  2. ExtJS 前端必须根据权限和角色进行更改
  3. 我使用卡片布局.第一个选项卡是登录屏幕,第二个选项卡是应用程序
  4. 在我的控制器中,我检查用户是否已登录.如果他有一个有效的身份,我将切换到选项卡 2.如果没有,他将返回到选项卡 1.

我现在的问题是我不确定第 2 部分和第 4 部分?你将如何实现这两个?

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

推荐答案

  • 一旦用户通过身份验证,将配置选项从服务器带到商店.例如: Ext.StoreManager.get('ConfigOptionStore').loadData(/* 从服务器返回的配置数据 */);
  • 使用 beforeRender 事件将组件添加到当前视图(在控制器中执行此操作),如下所示:

    • 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...
               }
           });
      }
      

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

    • 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天全站免登陆