ArticleDirectory
- User Management Module
- Implement User identity
In the "openexpressapp-user permission Module Design" of information system development platform, RBAC and Its Application in OEA are briefly introduced. The basis of permissions must exist with users for Custom User management, csla has provided some class libraries for inheritance and use. This article briefly explains how to use the csla class library to implement user management and login. The next article introduces the functional permissions section.
User Management Module
This is actually a user dictionary management, including the user name, login name and password, without considering the certificate and other functions, because the current implementation is relatively simple, the user class library is compiled according to the previous class library, I will not talk about it here separately.
Implement User principal
The logon and exit functions are enabled for the subject. After Successful Logon, the user is returned. Otherwise, the user is invalid. Csla implements a class businessprincipalbase. We can easily implement the principal object of OEA as long as it is inherited. This object is called during login window.
PrincipalCodeAs follows:
Public Class Oeaprincipal:Businessprincipalbase
{
Private Oeaprincipal (iidentity identity)
: Base (Identity)
{}
Public Static Bool Login( String Username, String Password)
{
VaR identity = Oeaidentity. getidentity (username, password );
If (Identity. isauthenticated)
{
Oeaprincipal principal = New Oeaprincipal (identity );
Csla. applicationcontext. User = Principal;
Return True ;
}
Else
{
Csla. applicationcontext. User = New Unauthenticatedprincipal ();
Return False ;
}
}
Public Static Void Logout()
{
Csla. applicationcontext. User = New Unauthenticatedprincipal ();
Implement User identity
After the user name and password are queried on the server side, the user identification object is returned. Here, the role is also returned, and some functional permissions of the role are described in the blog.
/// <Summary>
/// Note: duplicate names are not allowed. The user adds the code to differentiate and uniqueness. When querying, the code and name are returned at the same time.
/// </Summary>
[Serializable ()]
Public Class Oeaidentity:Cslaidentity
{
# Region Factory Methods
Internal Static Oeaidentity getidentity ( String Username, String Password)
{
Return Dataportal. Fetch < Oeaidentity > ( New Usernamecriteria (username, password ));
}
Public UserUser { Get ; Set ;}
Private Oeaidentity ()
{ /* Require use of factory methods */ }
# Endregion
# Region Data Access
Public New OrgpositionsRoles{ Get ; Private Set ;}
Private Void Dataportal_fetch (usernamecriteria criteria)
{
User = Userlist. Get (criteria. username, criteria. Password );
If ( Null ! = User)
{
Base . Name = User. Name;
Base . Isauthenticated = True ;
This . Roles = Orgpositions. getlist (user. ID ); // List of roles from security store
}
Else
{
Base . Name = String . Empty;
Base . Isauthenticated = False ;
This . Roles = Null ;
}
}
# Endregion
}
More information:Openexpressappframework for open source information system development platform