public void Configure(IApplicationBuilder app, IHostingEnvironment env, AppDbContext context,
                              IAuthenticateService userService)
        {
            app.UseAuthentication();

            context.Database.EnsureCreated();
            userService.Create(new User {
                Email = _settings.AdminLogin, Role = UserRole.Administrator
            },
                               _settings.AdminPassword);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCors(x => x
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader()
                        .AllowCredentials());


            app.UseMvc(rb =>
            {
                rb.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}"
                    );
                //defaults: new {controller = "Home", action = "Index"});
            });
        }
 public IActionResult AddAuditor([FromBody] UserAuthData user)
 {
     _authenticateService.Create(new User {
         Email = user.Email, Role = UserRole.Auditor
     }, user.Password);
     return(Ok());
 }
Exemple #3
0
        public async Task <IHttpActionResult> Register(UserDTO model)
        {
            await SetInitialData();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var result = await _authenticate.Create(model);

            return(!result.Succeeded ? GetErrorResult(result) : StatusCode(HttpStatusCode.Created));
        }