Ejemplo n.º 1
0
        public static void SetLifeTime(int lifeTime)
        {
            if (!CoreContext.UserManager.IsUserInGroup(SecurityContext.CurrentAccount.ID, Constants.GroupAdmin.ID))
            {
                throw new SecurityException();
            }

            var tenant   = TenantProvider.CurrentTenantID;
            var settings = TenantCookieSettings.GetForTenant(tenant);

            if (lifeTime > 0)
            {
                settings.Index    = settings.Index + 1;
                settings.LifeTime = lifeTime;
            }
            else
            {
                settings.LifeTime = 0;
            }

            TenantCookieSettings.SetForTenant(tenant, settings);

            if (lifeTime > 0)
            {
                DbLoginEventsManager.LogOutAllActiveConnectionsForTenant(tenant);
            }

            var userId = SecurityContext.CurrentAccount.ID;

            AuthenticateMeAndSetCookies(tenant, userId, MessageAction.LoginSuccess);
        }
Ejemplo n.º 2
0
        public static void ResetTenantCookie()
        {
            var userId = SecurityContext.CurrentAccount.ID;

            if (!CoreContext.UserManager.IsUserInGroup(userId, Constants.GroupAdmin.ID))
            {
                throw new SecurityException();
            }

            var tenant   = TenantProvider.CurrentTenantID;
            var settings = TenantCookieSettings.GetForTenant(tenant);

            settings.Index = settings.Index + 1;
            TenantCookieSettings.SetForTenant(tenant, settings);

            DbLoginEventsManager.LogOutAllActiveConnectionsForTenant(tenant);

            AuthenticateMeAndSetCookies(tenant, userId, MessageAction.LoginSuccess);
        }