Openexpressapp, information system development platform-use csla class library for user management

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.