ISecurityUserWithLoginInfo Interface
Returns an associated ISecurityUserLoginInfo collection.
Namespace: DevExpress.ExpressApp.Security
Assembly: DevExpress.ExpressApp.v24.1.dll
NuGet Package: DevExpress.ExpressApp
Declaration
Remarks
XAF has a built-in PermissionPolicyUser
type for XPO and EF Core-based applications. Use it when an application employs only standard authentication or Windows Active Directory authentication.
When a user has multiple ways to log in, you need to store information for all authentication types and associate this information with the user. To do this, use the ISecurityUserWithLoginInfo
(a descendant of ISecurityUser and IOAuthSecurityUser
) and ISecurityUserLoginInfo interfaces.
The Project Wizard generates classes that implement these interfaces automatically for projects created with v21.1 and later.
The following example shows how to use the ISecurityUserWithLoginInfo
interface to store a user’s authentication methods:
using System.Collections.ObjectModel;
using System.ComponentModel;
using DevExpress.ExpressApp.Security;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl.EF;
using DevExpress.Persistent.BaseImpl.EF.PermissionPolicy;
namespace MainDemo.Module.BusinessObjects;
[CurrentUserDisplayImage(nameof(Photo))]
[DefaultProperty(nameof(UserName))]
public class ApplicationUser : PermissionPolicyUser, ISecurityUserWithLoginInfo {
public ApplicationUser() { }
[Browsable(false)]
[DevExpress.ExpressApp.DC.Aggregated]
public virtual IList<ApplicationUserLoginInfo> UserLogins { get; set; } = new ObservableCollection<ApplicationUserLoginInfo>();
IEnumerable<ISecurityUserLoginInfo> IOAuthSecurityUser.UserLogins => UserLogins;
[VisibleInListView(false)]
[ImageEditor(ListViewImageEditorCustomHeight = 75, DetailViewImageEditorFixedHeight = 150)]
public virtual MediaDataObject Photo { get; set; }
ISecurityUserLoginInfo ISecurityUserWithLoginInfo.CreateUserLoginInfo(string loginProviderName, string providerUserKey) {
ApplicationUserLoginInfo result = ObjectSpace.CreateObject<ApplicationUserLoginInfo>();
result.LoginProviderName = loginProviderName;
result.ProviderUserKey = providerUserKey;
result.User = this;
return result;
}
public override void OnCreated() {
Photo = ObjectSpace.CreateObject<MediaDataObject>();
}
}