예제 #1
0
        public Task Consume(ConsumeContext <IPermanentUserAccessAllowed> context)
        {
            var hash = new UserHash(context.Message.UserName, context.Message.BiometricHash);

            _accessPermissions.AddOrUpdatePermission(new PermanentUserAccess(context.Message.AccessPointId, hash));
            _service.Save(_accessPermissions);
            return(Task.FromResult(true));
        }
예제 #2
0
        public Task Consume(ConsumeContext <IScheduledUserAccessAllowed> context)
        {
            var hash       = new UserHash(context.Message.UserName, context.Message.BiometricHash);
            var permission = new ScheduledUserAccess(context.Message.AccessPointId, hash, WeeklySchedule.Convert(context.Message.WeeklySchedule));

            _accessPermissions.AddOrUpdatePermission(permission);
            _service.Save(_accessPermissions);
            return(Task.FromResult(true));
        }
예제 #3
0
        private void CheckAuthorization()
        {
            var userHash = UserHash.FromUserData(Login);

            if (Authorization.CheckAuthorization(userHash))
            {
                OnAccept?.Invoke();
            }
        }
예제 #4
0
        private UserHash[] CombineHashes(string[] usersInGroup, string[] userHashes)
        {
            var hashes = new UserHash[usersInGroup.Length];

            for (var i = 0; i < usersInGroup.Length; i++)
            {
                hashes[i] = new UserHash(usersInGroup[i], userHashes[i]);
            }
            return(hashes);
        }
예제 #5
0
        public static bool ClearAllAssocitedCaches(string userId, string noificationType)
        {
            try
            {
                //ConnectionMultiplexer con = ConnectionMultiplexer.Connect(Sahara.Core.Settings.Azure.Redis.RedisConnections.AccountManager_RedisConfiguration);
                //IDatabase cache = con.GetDatabase();

                //IDatabase cache = Sahara.Core.Settings.Azure.Redis.RedisMultiplexers.AccountManager_Multiplexer.GetDatabase();
                IDatabase cache = Sahara.Core.Settings.Azure.Redis.RedisMultiplexers.RedisMultiplexer.GetDatabase();

                string userKey = UserHash.Key(userId);

                /*
                 * string allNotificationsUnread = UserHash.Fields.Notifications(NotificationStatus.Unread.ToString());
                 * string allNotificationsRead = UserHash.Fields.Notifications(NotificationStatus.Read.ToString());
                 * string allNotificationsExpiredUnread = UserHash.Fields.Notifications(NotificationStatus.ExpiredUnread.ToString());
                 * string allNotificationsExpiredRead = UserHash.Fields.Notifications(NotificationStatus.ExpiredRead.ToString());
                 * */

                string unreadNotificationsField        = UserHash.Fields.Notifications(noificationType, NotificationStatus.Unread.ToString());
                string readNotificationsField          = UserHash.Fields.Notifications(noificationType, NotificationStatus.Read.ToString());
                string expiredUnreadNotificationsField = UserHash.Fields.Notifications(noificationType, NotificationStatus.ExpiredUnread.ToString());
                string expiredReadNotificationsField   = UserHash.Fields.Notifications(noificationType, NotificationStatus.ExpiredRead.ToString());

                try
                {
                    cache.HashDelete(userKey, unreadNotificationsField, CommandFlags.FireAndForget);
                    cache.HashDelete(userKey, readNotificationsField, CommandFlags.FireAndForget);
                    cache.HashDelete(userKey, expiredUnreadNotificationsField, CommandFlags.FireAndForget);
                    cache.HashDelete(userKey, expiredReadNotificationsField, CommandFlags.FireAndForget);
                }
                catch
                {
                }


                //con.Close();

                return(true);
            }
            catch (Exception e)
            {
                //Log exception and email platform admins
                PlatformExceptionsHelper.LogExceptionAndAlertAdmins(
                    e,
                    "attempting to clear all notification caches for: " + userId,
                    System.Reflection.MethodBase.GetCurrentMethod()
                    );

                return(false);
            }
        }
예제 #6
0
        public void Visit(ScheduledGroupAccess permission)
        {
            var hashes = permission.UserHashes.ToList();
            var index  = hashes.FindIndex(x => string.Equals(x.UserName, _userName));

            if (index == -1)
            {
                return;
            }

            var old = hashes[index];

            hashes[index] = new UserHash(old.UserName, _newHash);
            var replacement = new ScheduledGroupAccess(permission.AccessPointId, permission.UserGroupName, hashes.ToArray(), permission.WeeklySchedule);

            _accessPermissions.AddOrUpdatePermission(replacement);
        }
예제 #7
0
        internal static void DeleteUserHashReference(string userId)
        {
            //ConnectionMultiplexer con = ConnectionMultiplexer.Connect(Sahara.Core.Settings.Azure.Redis.RedisConnections.AccountManager_RedisConfiguration);
            //IDatabase cache = con.GetDatabase();

            //IDatabase cache = Sahara.Core.Settings.Azure.Redis.RedisMultiplexers.AccountManager_Multiplexer.GetDatabase();
            IDatabase cache = Sahara.Core.Settings.Azure.Redis.RedisMultiplexers.RedisMultiplexer.GetDatabase();

            try
            {
                //Delete the entire Hash for this user
                cache.KeyDelete(UserHash.Key(userId), CommandFlags.FireAndForget);
            }
            catch
            {
            }
        }
예제 #8
0
        internal static void DeleteAllUserCacheReferences(AccountUser accountUser)
        {
            //ConnectionMultiplexer con = ConnectionMultiplexer.Connect(Sahara.Core.Settings.Azure.Redis.RedisConnections.AccountManager_RedisConfiguration);
            //IDatabase cache = con.GetDatabase();

            //IDatabase cache = Sahara.Core.Settings.Azure.Redis.RedisMultiplexers.AccountManager_Multiplexer.GetDatabase();
            IDatabase cache = Sahara.Core.Settings.Azure.Redis.RedisMultiplexers.RedisMultiplexer.GetDatabase();

            try
            {
                //Delete the entire Hash for this user
                cache.KeyDelete(UserHash.Key(accountUser.Id.ToString()), CommandFlags.FireAndForget);

                //Delete the id lookup table
                cache.HashDelete(UserIdByUserNameHash.Key(accountUser.UserName), UserIdByUserNameHash.Fields.UserId(accountUser.UserName), CommandFlags.FireAndForget);
            }
            catch
            {
            }
        }
예제 #9
0
        private void bnLogin_Click(object sender, EventArgs e)
        {
            string strHash = UserHash.HashUserInfo(this.textBoxUser.Text,
                                                   this.maskedTextBoxPW.Text);

            m_nSession = userMge.Login(this.textBoxUser.Text, strHash);

            //this.labelHashUser.Text = strHash + " s: " + m_nSession.ToString();
            if (m_nSession > 0)
            {
                this.tabControl1.SelectedIndex = 1;
                strUserLogin = this.textBoxUser.Text;
                this.textBoxLoginUser.Text           = strUserLogin;
                this.comboBoxUserRight.SelectedIndex = 4;

                this.Text = "MCS Control  Login User: "******"Login failed, please check your user name and password.");
            }
        }
예제 #10
0
 public static string GetLogin(UserHash hash)
 {
     return(hash.ToString());
 }