Esempio n. 1
0
        protected override bool PostSave(ITransaction transaction)
        {
            if (IsInsert && RevokeTime == null) // Is insert, not revoking
            {
                SecurityProfile securityProfile = new SecurityProfile();
                securityProfile.AccessToken = AccessToken.ToString();
                securityProfile.Expiration  = Expiration.Value;
                securityProfile.UserID      = UserID.Value;

                User user = DataObject.GetReadOnlyByPrimaryKey <User>(UserID, transaction, new string[] { "UserPermissions.Permission.Key" });
                securityProfile.Permissions.AddRange(user.UserPermissions.Select(up => up.Permission.Key));

                SecurityCache.AddSecurityProfile(securityProfile);
            }

            if (IsFieldDirty("RevokeTime") && RevokeTime != null)
            {
                SecurityCache.Revoke(AccessToken.ToString());
            }
            return(base.PostSave(transaction));
        }
Esempio n. 2
0
 public void Grant(SecurityProfile profile)
 {
     SecurityCache.AddSecurityProfile(profile);
 }