Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

LuAuthExtensions.cs 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System.Collections.Generic;
  2. using Luticate2.Auth.Business;
  3. using Luticate2.Auth.DataAccess;
  4. using Luticate2.Auth.Middlewares;
  5. using Luticate2.Utils.Controllers;
  6. using Luticate2.Utils.Dbo.OrderBy;
  7. using Microsoft.AspNetCore.Builder;
  8. using Microsoft.AspNetCore.Http;
  9. using Microsoft.AspNetCore.Mvc;
  10. using Microsoft.Extensions.DependencyInjection;
  11. namespace Luticate2.Auth.Controllers
  12. {
  13. public static class LuAuthExtensions
  14. {
  15. public static IServiceCollection AddLuticateAuth(this IServiceCollection services)
  16. {
  17. services.AddLuticatUtils();
  18. services.AddSingleton<LuGroupsController>();
  19. services.AddSingleton<LuGroupsBusiness>();
  20. services.AddSingleton<LuGroupsDataAccess>();
  21. services.AddSingleton<LuUsersController>();
  22. services.AddDbContext<LuDatabaseContext>();
  23. return services;
  24. }
  25. public static IMvcBuilder AddLuticateAuth(this IMvcBuilder builder)
  26. {
  27. builder.AddLuticatUtils();
  28. // builder.AddApplicationPart(typeof(LuController).GetTypeInfo().Assembly)
  29. // .AddControllersAsServices();
  30. builder.Services.Configure<MvcOptions>(
  31. options => options.ModelBinderProviders.Insert(0, new LuOrderByBinderProvider()));
  32. return builder;
  33. }
  34. public static IApplicationBuilder UseLuticateAuth(this IApplicationBuilder app)
  35. {
  36. app.UseLuticateUtils();
  37. app.UseMiddleware<LuAuthMiddleware>();
  38. return app;
  39. }
  40. public static object GetLuCurrentUser(this HttpContext context)
  41. {
  42. return context.GetLuItems()["currentUser"];//TODO
  43. }
  44. }
  45. }