fixe l'accès web au chat privé

This commit is contained in:
2016-11-03 14:52:17 +01:00
parent a6f4af29c2
commit 8a66b578a3
18 changed files with 2403 additions and 104 deletions

View File

@ -31,9 +31,9 @@ namespace Yavsc
public partial class Startup
{
public static string ConnectionString { get; private set; }
public static string Authority { get; private set; }
public static string Audience { get; private set; }
public static string ConnectionString { get; private set; }
public static string Authority { get; private set; }
public static string Audience { get; private set; }
private static ILogger logger;
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
@ -75,11 +75,11 @@ namespace Yavsc
var oauthFacebookSettings = Configuration.GetSection("Authentication").GetSection("Facebook");
services.Configure<FacebookOAuth2AppSettings>(oauthFacebookSettings);
/* services.Configure<MvcOptions>(options =>
{
options.Filters.Add(new ProducesAttribute("text/x-tex"));
options.Filters.Add(new ProducesAttribute("text/pdf"));
});*/
/* services.Configure<MvcOptions>(options =>
{
options.Filters.Add(new ProducesAttribute("text/x-tex"));
options.Filters.Add(new ProducesAttribute("text/pdf"));
});*/
services.Configure<RequestLocalizationOptions>(options =>
{
@ -114,15 +114,15 @@ namespace Yavsc
//}));
});
services.Add(ServiceDescriptor.Singleton(typeof(IOptions<SiteSettings>), typeof(OptionsManager<SiteSettings>)));
services.Add(ServiceDescriptor.Singleton(typeof(IOptions<SmtpSettings>), typeof(OptionsManager<SmtpSettings>)));
services.Add(ServiceDescriptor.Singleton(typeof(IOptions<GoogleAuthSettings>), typeof(OptionsManager<GoogleAuthSettings>)));
services.Add(ServiceDescriptor.Singleton(typeof(IOptions<CompanyInfoSettings>), typeof(OptionsManager<CompanyInfoSettings>)));
// DataProtection
ConfigureProtectionServices(services);
// DataProtection
ConfigureProtectionServices(services);
// Add framework services.
services.AddEntityFramework()
@ -130,7 +130,7 @@ namespace Yavsc
.AddDbContext<ApplicationDbContext>(options => options.UseNpgsql(ConnectionString))
;
ConfigureOAuthServices(services);
ConfigureOAuthServices(services);
services.AddCors(
/*
@ -273,42 +273,52 @@ namespace Yavsc
else throw ex;
}
}
Task.Run(async ()=>{
Task.Run(async () =>
{
// Creates roles when they don't exist
foreach (string roleName in new string[] {Constants.AdminGroupName,
Constants.StarGroupName, Constants.PerformerGroupName,
Constants.StarGroupName, Constants.PerformerGroupName,
Constants.FrontOfficeGroupName,
Constants.StarHunterGroupName
})
if (!await roleManager.RoleExistsAsync(roleName))
{
var role = new IdentityRole { Name = roleName };
var resultCreate = await roleManager.CreateAsync(role);
if (!resultCreate.Succeeded)
if (!await roleManager.RoleExistsAsync(roleName))
{
var role = new IdentityRole { Name = roleName };
var resultCreate = await roleManager.CreateAsync(role);
if (!resultCreate.Succeeded)
{
throw new Exception("The role '{roleName}' does not exist and could not be created.");
}
}
// FIXME In a perfect world, connection records should be dropped at shutdown, but:
using (var db = new ApplicationDbContext())
{
throw new Exception("The role '{roleName}' does not exist and could not be created.");
foreach (var c in db.Connections)
db.Connections.Remove(c);
db.SaveChanges();
}
}
});
app.UseIISPlatformHandler(options =>
{
options.AuthenticationDescriptions.Clear();
options.AutomaticAuthentication = false;
});
Authority = siteSettings.Value.Authority;
Audience = siteSettings.Value.Audience;
ConfigureOAuthApp(app,siteSettings.Value);
app.UseSignalR("/api/signalr");
ConfigureFileServerApp(app,siteSettings.Value,env);
ConfigureOAuthApp(app, siteSettings.Value);
app.UseWebSockets();
app.UseRequestLocalization(localizationOptions.Value, (RequestCulture) new RequestCulture((string)"en"));
app.UseSignalR("/api/signalr");
ConfigureFileServerApp(app, siteSettings.Value, env);
app.UseRequestLocalization(localizationOptions.Value, (RequestCulture)new RequestCulture((string)"en"));
app.UseMvc(routes =>
{
@ -317,7 +327,7 @@ namespace Yavsc
template: "{controller=Home}/{action=Index}/{id?}");
});
}
// Entry point for the application.
public static void Main(string[] args) => Microsoft.AspNet.Hosting.WebApplication.Run<Startup>(args);
}