You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LuAuthExtensions.cs 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. return builder;
  31. }
  32. public static IApplicationBuilder UseLuticateAuth(this IApplicationBuilder app)
  33. {
  34. app.UseLuticateUtils();
  35. app.UseMiddleware<LuAuthMiddleware>();
  36. return app;
  37. }
  38. public static object GetLuCurrentUser(this HttpContext context)
  39. {
  40. return context.GetLuItems()["currentUser"];//TODO
  41. }
  42. }
  43. }