如何在win形式的MVP应用程序中处理用户权限 [英] How to handle user permission in a win forms MVP application

查看:58
本文介绍了如何在win形式的MVP应用程序中处理用户权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows窗体工资单应用程序(对于小规模客户端)中,我按如下方式规划用户权限处理。



注意:系统可以由少数用户同时使用(最多3个),数据库在服务器端。





数据库中的用户表。



USER(user_id [ pk],name,access_level,status)



PERMISSION(permission_id [pk],permission_detail)



USER_PERMISSION(user_id [pk] [fk],permission_id [pk] [fk])





我会在`USER中维护用户列表`'PERMISSION`表中的表和权限列表(权限详细信息是可访问的模块名称)。中间表`USER_PERMISSION`将使用权限映射用户。 `UESR`和`PERMISSION`表与`USER_PERMISSION`表有'1:M`关系。



当用户登录系统时,首先系统将验证如果用户有效,则显示主屏幕,并且记录用户的ID将保存在每个演示者可访问的全局变量中。当用户尝试访问特定模块时,系统将读取该全局变量以查找当前用户的ID,然后它将在USER_PERMISSION表中查找是否存在与该用户ID和模块名称相关的条目用户正在尝试登录。如果有和入口,则用户将被授予对该特定模块的访问权限。



当用户注销时,将清除保存当前用户ID的变量。



1.在这种方法中,可以将当前用户的ID保存在应用程序内存中吗?或者应该写入本地文件?



2.应该跟踪表格中数据的修改,为此我应该在每个表格上保留一个单独的列(应该监控哪些)来保存正在修改记录的用户的ID?



编辑



3.我们可以在此目的中使用`SQL-SERVER`用户名/登录吗?并且这个用户操作登录的东西可以移交给`SQL-SERVER`吗?



当在`Forms`中控制`Read / Write`权限时,各自的`Presenter `根据当前用户权限处理逻辑并在`View`中设置属性(如`IsModifyAllowed {get; set;}`,`IsDeleteAllowed {get; set;}`等属性)。因此View可以通过`View`中的启用/禁用控制器来处理其余的事情。



4.在这种方法中,每个模型都应该有一个匹配的属性,如视图中(在这种情况下`IsModifyAllowed {get; set;}`等)?



5.什么是最广泛使用的方法这种情况?

In a windows forms payroll application (for a small scale client) I'm planing user permission handling as follows.

NOTE : System could be simultaneously used by few users (maximum 3) and the database is at the server side.


User Tables in the database.

USER (user_id[pk], name, access_level, status)

PERMISSION (permission_id[pk], permission_detail)

USER_PERMISSION (user_id[pk][fk], permission_id[pk][fk])


I would maintain user list in `USER` table and permission list in `PERMISSION` table (permission details are the accessible module names). Intermediate table `USER_PERMISSION` would map the users with the permissions. `UESR` and `PERMISSION` tables have `1:M` relationships with `USER_PERMISSION` table.

When an user login to the system, first the system will validate the user and if its valid then the home screen will be shown and the logged user's `ID` will be hold in a global variable accessible to every presenter. When the user try to access a specific module, the system will read that global variable to find the current user's `ID` and then it will look in the `USER_PERMISSION` table whether there is an entry relevant to that user id and the module name in which the user is trying to login. If there is and entry, then the user will be given the access to that particular module.

When user log off the variable holding the current user id will be cleared.

1. In this approach is it okay to hold the current user's `ID` in application memory? or should be written to a local file?

2. Modifications to the data in the tables should be tracked and in this purpose should I maintain a separate column on each table (ones should be monitored) to hold the `ID` of the user who is modifying the record?

EDIT:

3. Can we use `SQL-SERVER` user rolls/ logins in this purpose? and can this user action login stuff be handed over to `SQL-SERVER`?

When controlling `Read/Write` permissions in `Forms`, the respective `Presenter` handle the logic and set the properties in the `View` (properties like `IsModifyAllowed{get;set;}`, `IsDeleteAllowed{get;set;}` etc.) according to the current users permissions. So that the View could handle the rest of the things by `enabling / disabling` controllers in the `View`.

4. In this approach should the every Model have a matching property like in the view(in this case `IsModifyAllowed{get; set;}` etc. )?

5. What is the most widely used approach in this case?

推荐答案

这篇关于如何在win形式的MVP应用程序中处理用户权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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