-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathApplicationUser.cs
58 lines (53 loc) · 2.57 KB
/
ApplicationUser.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Security;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.BaseImpl.PermissionPolicy;
using DevExpress.Persistent.Validation;
using DevExpress.Xpo;
namespace MySolution.Module.BusinessObjects {
#pragma warning disable XAF0023
[MapInheritance(MapInheritanceType.ParentTable)]
[DefaultProperty(nameof(UserName))]
public class ApplicationUser : PermissionPolicyUser, IObjectSpaceLink, ISecurityUserWithLoginInfo {
public ApplicationUser(Session session) : base(session) { }
[Browsable(false)]
[Aggregated, Association("User-LoginInfo")]
public XPCollection<ApplicationUserLoginInfo> LoginInfo {
get { return GetCollection<ApplicationUserLoginInfo>(nameof(LoginInfo)); }
}
IEnumerable<ISecurityUserLoginInfo> IOAuthSecurityUser.UserLogins => LoginInfo.OfType<ISecurityUserLoginInfo>();
IObjectSpace IObjectSpaceLink.ObjectSpace { get; set; }
ISecurityUserLoginInfo ISecurityUserWithLoginInfo.CreateUserLoginInfo(string loginProviderName, string providerUserKey) {
ApplicationUserLoginInfo result = ((IObjectSpaceLink)this).ObjectSpace.CreateObject<ApplicationUserLoginInfo>();
result.LoginProviderName = loginProviderName;
result.ProviderUserKey = providerUserKey;
result.User = this;
return result;
}
public bool EnableStandardAuthentication {
get { return GetPropertyValue<bool>(nameof(EnableStandardAuthentication)); }
set { SetPropertyValue(nameof(EnableStandardAuthentication), value); }
}
[Association, Aggregated]
public XPCollection<EmailEntity> OAuthAuthenticationEmails {
get { return GetCollection<EmailEntity>(nameof(OAuthAuthenticationEmails)); }
}
}
public class EmailEntity : BaseObject {
public EmailEntity(Session session) : base(session) {
}
[RuleUniqueValue("Unique_Email", DefaultContexts.Save, CriteriaEvaluationBehavior = CriteriaEvaluationBehavior.BeforeTransaction)]
public string Email {
get { return GetPropertyValue<string>(nameof(Email)); }
set { SetPropertyValue(nameof(Email), value); }
}
[Association]
public ApplicationUser ApplicationUser {
get { return GetPropertyValue<ApplicationUser>(nameof(ApplicationUser)); }
set { SetPropertyValue(nameof(ApplicationUser), value); }
}
}
}