Skip to content
Snippets Groups Projects
Commit c9fdda18 authored by esantangelo's avatar esantangelo
Browse files

commit

parent 98b28b5f
No related branches found
No related tags found
3 merge requests!20merge from develop,!16Feature/chat signalr,!15Feature/upload file
......@@ -6,6 +6,7 @@ using System.Text;
using System.Threading.Tasks;
using AutoMapper;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
......@@ -14,6 +15,7 @@ using Microsoft.AspNetCore.StaticFiles;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
......@@ -79,7 +81,14 @@ namespace Tsi1.Api
services.AddScoped<IEmailService, EmailService>();
services.AddCors();
services.AddAuthorization(options =>
{
options.FallbackPolicy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
});
services.AddAuthentication(x =>
{
x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
......@@ -151,14 +160,6 @@ namespace Tsi1.Api
c.DocumentTitle = "Tsi1 api";
});
var provider = new FileExtensionContentTypeProvider();
app.UseStaticFiles(new StaticFileOptions()
{
ContentTypeProvider = provider,
RequestPath = "/static"
}
); ;
app.UseRouting();
app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
......@@ -166,6 +167,16 @@ namespace Tsi1.Api
app.UseAuthentication();
app.UseAuthorization();
var provider = new FileExtensionContentTypeProvider();
app.UseStaticFiles(new StaticFileOptions()
{
ContentTypeProvider = provider,
FileProvider = new PhysicalFileProvider(
Path.Combine(env.ContentRootPath, "StaticFiles")),
RequestPath = "/static"
}
);
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
......
......@@ -14,5 +14,9 @@
<ProjectReference Include="..\Tsi1.BusinessLayer\Tsi1.BusinessLayer.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="StaticFiles\" />
</ItemGroup>
</Project>
......@@ -27,7 +27,7 @@ namespace Tsi1.BusinessLayer.Services
{
_context = context;
_mapper = mapper;
_path = hostingEnvironment.ContentRootPath + "/wwwroot";
_path = hostingEnvironment.ContentRootPath + "/StaticFiles";
}
public async Task<ServiceResult<string>> SaveFile(IFormFile file, string filePath)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment