您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

LuAuthExtensions.cs 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using Luticate2.Auth.Business;
  2. using Luticate2.Auth.DataAccess;
  3. using Luticate2.Auth.Middlewares;
  4. using Luticate2.Utils.Controllers;
  5. using Microsoft.AspNetCore.Builder;
  6. using Microsoft.AspNetCore.Http;
  7. using Microsoft.Extensions.DependencyInjection;
  8. namespace Luticate2.Auth.Controllers
  9. {
  10. public static class LuAuthExtensions
  11. {
  12. public static IServiceCollection AddLuticateAuth(this IServiceCollection services, LuUtilsExtensions.LuOptionsDelegate optionsDelegate)
  13. {
  14. services.AddLuticateUtils(optionsDelegate);
  15. services.AddSingleton<LuGroupsController>();
  16. services.AddSingleton<LuGroupsBusiness>();
  17. services.AddSingleton<LuGroupsDataAccess>();
  18. services.AddSingleton<LuUsersController>();
  19. services.AddDbContext<LuDatabaseContext>();
  20. return services;
  21. }
  22. public static IMvcBuilder AddLuticateAuth(this IMvcBuilder builder)
  23. {
  24. builder.AddLuticateUtils();
  25. return builder;
  26. }
  27. public static IApplicationBuilder UseLuticateAuth(this IApplicationBuilder app)
  28. {
  29. app.UseLuticateUtils();
  30. app.UseMiddleware<LuAuthMiddleware>();
  31. return app;
  32. }
  33. public static object GetLuCurrentUser(this HttpContext context)
  34. {
  35. return context.GetLuItems()["currentUser"];//TODO
  36. }
  37. }
  38. }