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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System;
  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.Basic;
  7. using Microsoft.AspNetCore.Builder;
  8. using Microsoft.AspNetCore.Http;
  9. using Microsoft.Extensions.DependencyInjection;
  10. namespace Luticate2.Auth.Controllers
  11. {
  12. public static class LuAuthExtensions
  13. {
  14. public static IServiceCollection AddLuticateAuth(this IServiceCollection services, Action<LuUtilsOptionsDbo> optionsDelegate)
  15. {
  16. services.AddLuticateUtils(optionsDelegate);
  17. services.AddSingleton<LuGroupsController>();
  18. services.AddSingleton<LuGroupsBusiness>();
  19. services.AddSingleton<LuGroupsDataAccess>();
  20. services.AddSingleton<LuUsersController>();
  21. services.AddDbContext<LuDatabaseContext>();
  22. return services;
  23. }
  24. public static IMvcBuilder AddLuticateAuth(this IMvcBuilder builder)
  25. {
  26. builder.AddLuticateUtils();
  27. return builder;
  28. }
  29. public static IApplicationBuilder UseLuticateAuth(this IApplicationBuilder app)
  30. {
  31. app.UseLuticateUtils();
  32. app.UseMiddleware<LuAuthMiddleware>();
  33. return app;
  34. }
  35. public static object GetLuCurrentUser(this HttpContext context)
  36. {
  37. return context.GetLuItems()["currentUser"];//TODO
  38. }
  39. }
  40. }