Example #1
0
        public async Task ShouldNotLoginIfEmailConfirmationIsEnabledAndUserHasNotConfirmed()
        {
            Resolve <IMultiTenancyConfig>().IsEnabled = true;

            //Set session
            StudioXSession.TenantId = 1;
            StudioXSession.UserId   = 1;

            //Email confirmation is disabled as default
            (await logInManager.LoginAsync("user1", "123qwe", Tenant.DefaultTenantName)).Result.ShouldBe(StudioXLoginResultType.Success);

            //Change configuration
            await Resolve <ISettingManager>().ChangeSettingForTenantAsync(StudioXSession.GetTenantId(), StudioXZeroSettingNames.UserManagement.IsEmailConfirmationRequiredForLogin, "true");

            //Email confirmation is enabled now
            (await logInManager.LoginAsync("user1", "123qwe", Tenant.DefaultTenantName)).Result.ShouldBe(StudioXLoginResultType.UserEmailIsNotConfirmed);
        }
Example #2
0
 protected virtual Task <Tenant> GetCurrentTenantAsync()
 {
     return(TenantManager.GetByIdAsync(StudioXSession.GetTenantId()));
 }
Example #3
0
        /// <summary>
        /// Gets current tenant if <see cref="IStudioXSession.TenantId"/> is not null.
        /// Throws exception if there is no current tenant.
        /// </summary>
        protected async Task <Tenant> GetCurrentTenantAsync()
        {
            var tenantId = StudioXSession.GetTenantId();

            return(await UsingDbContext(context => context.Tenants.SingleAsync(t => t.Id == tenantId)));
        }
Example #4
0
        /// <summary>
        /// Gets current tenant if <see cref="IStudioXSession.TenantId"/> is not null.
        /// Throws exception if there is no current tenant.
        /// </summary>
        protected Tenant GetCurrentTenant()
        {
            var tenantId = StudioXSession.GetTenantId();

            return(UsingDbContext(null, context => context.Tenants.Single(t => t.Id == tenantId)));
        }