Esempio n. 1
0
        private CmsMembershipProvider GetMembershipProvider(ISession session)
        {
            var userService  = new DefaultUserService(GetRepository(session), GetAuthenticationService(session), GetUnitOfWork(session));
            var roleProvider = new CmsMembershipProvider(userService, authenticationService, GetUnitOfWork(session), "CmsMembershipProvider");

            return(roleProvider);
        }
Esempio n. 2
0
        public void TestSave()
        {
            var dbContextOptionBuilder = new DbContextOptionsBuilder <UserDbContext>();

            dbContextOptionBuilder.UseSqlServer(ConnectionString);
            var accessores = new Dictionary <string, IDataAccessor <DataAccess.UserInfo> >
            {
                { "default", new UserInfoDataAccessor(new UserDbContextCreator(dbContextOptionBuilder.Options)) }
            };
            var repository  = new DefaultUserInfoRepository(accessores);
            var business    = new DefaultUserInfoBusiness(repository);
            var userService = new DefaultUserService(business);

            userService.Save(new UserInfo()
            {
                GivenName = "Bar", Surname = "Foo"
            });
        }
        public JsonResult Login(string type, string userId, string password)
        {
            UserService userService = new DefaultUserService();

            switch (type)
            {
            case "db":
                userService = new DbAuthenticationUserService(userService);
                break;

            case "ldap":
                userService = new AuthorityUserService(new LdapAuthenticationUserService(userService));
                break;

            default:
                break;
            }
            return(Json(new Result()
            {
                User = userService.Login(userId, password), Acl = userService.GetAclList(userId)
            }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        public async Task should_not_send_forgot_password_email_when_external_auth_enabled()
        {
            var externalIdpEnabledOptions = new Mock <IOptions <ExternalIdentityServiceOptions> >();

            externalIdpEnabledOptions.Setup(op => op.Value).Returns(new ExternalIdentityServiceOptions {
                IsEnabled = true
            });

            var(mockDeliveryMethod, mockUrlHelper, mockForgotPasswordEmailBuilder) = CreateRelatedMockItems();
            var userService = new DefaultUserService(externalIdpEnabledOptions.Object,
                                                     null, _app.GetService <UserManager <User> >(),
                                                     mockDeliveryMethod.Object, mockUrlHelper.Object, null, mockForgotPasswordEmailBuilder.Object,
                                                     null, null, null, null, externalIdpEnabledOptions.Object);

            await Assert.ThrowsAsync <InvalidOperationException>(async() =>
            {
                await userService.SendEmailRetrievePasswordAsync(new User(), "https");
            });

            mockDeliveryMethod.VerifyNoOtherCalls();
            mockUrlHelper.VerifyNoOtherCalls();
            mockUrlHelper.VerifyNoOtherCalls();
        }
    public void ConfigureServices(IServiceCollection services)
    {
        services.Configure <CookiePolicyOptions>(options => options.MinimumSameSitePolicy = SameSiteMode.Lax);
        services.Configure <CloudMailSenderSettings>(Configuration.GetSection("SendGrid"));
        services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
        .AddCookie();
        if (Environment.IsDevelopment())
        {
            var s = new DefaultUserService
            {
                Username = Configuration.GetValue <string>("Username"),
                Password = Configuration.GetValue <string>("Password")
            };
            services.AddSingleton(s);
        }
        else
        {
            services.AddSingleton(new DefaultUserService());
        }
        services.AddRazorPages();
        services.AddControllers().AddJsonOptions(options =>
        {
            options.JsonSerializerOptions.AllowTrailingCommas = true;
            //options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.Preserve;
            options.JsonSerializerOptions.WriteIndented = true;
        });
        services.AddSwaggerGen(c => c.SwaggerDoc("v1", new OpenApiInfo {
            Title = "Modules Registry API", Version = "v1"
        }));
        services.AddServerSideBlazor().AddCircuitOptions(options => { options.DetailedErrors = true; });;
        services.AddHttpContextAccessor();
        services.AddScoped <HttpContextAccessor>();
        services.AddHttpClient();
        services.AddScoped <HttpClient>();
        services.AddAuthorizationPolicies();
        services.AddDbContextFactory <ModulesDbContext>(options =>
        {
            options.UseSqlServer(Configuration.GetConnectionString("TimetablePlanningDatabase"))
            .EnableSensitiveDataLogging(Environment.IsDevelopment());
        });

        services.AddBlazoredToast();
        services.AddScoped <IClaimsTransformation, ApplicationClaimsTransformation>();
        services.AddScoped <ILanguageService, LanguageService>();
        services.AddScoped <ITimeProvider, SystemTimeProvider>();
        services.AddScoped <PageHistory>();
        if (Environment.IsProduction())
        {
            services.AddScoped <IMailSender, CloudMailSender>();
        }
        if (Environment.IsDevelopment())
        {
            services.AddScoped <IMailSender, LoggingOnlyMailSender>();
        }
        services.AddScoped <CargoService>();
        services.AddScoped <StationCustomerService>();
        services.AddScoped <ContentService>();
        services.AddScoped <CountryService>();
        services.AddScoped <DocumentService>();
        services.AddScoped <ExternalStationService>();
        services.AddScoped <GroupCategoryService>();
        services.AddScoped <GroupService>();
        services.AddScoped <LayoutService>();
        services.AddScoped <MeetingService>();
        services.AddScoped <ModuleService>();
        services.AddScoped <ModuleGableTypeService>();
        services.AddScoped <ModuleStandardService>();
        services.AddScoped <OperatingDayService>();
        services.AddScoped <PersonService>();
        services.AddScoped <PropertyService>();
        services.AddScoped <RegionService>();
        services.AddScoped <StationService>();
        services.AddScoped <ScaleService>();
        services.AddScoped <UserService>();
        services.AddScoped <WaybillService>();

        services.AddLocalization(options => options.ResourcesPath = "Resources");
        services.AddRequestLocalization(options =>
        {
            options.DefaultRequestCulture = new RequestCulture(LanguageUtility.DefaultLanguage);
            options.AddSupportedCultures(LanguageUtility.FullySupportedLanguages);
            options.AddSupportedUICultures(LanguageUtility.FullySupportedLanguages);
        });
    }