1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System.Collections.Generic;
- using Luticate2.Auth.Business;
- using Luticate2.Auth.DataAccess;
- using Luticate2.Auth.Middlewares;
- using Luticate2.Utils.Controllers;
- using Luticate2.Utils.Dbo.OrderBy;
- using Microsoft.AspNetCore.Builder;
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.DependencyInjection;
-
- namespace Luticate2.Auth.Controllers
- {
- public static class LuAuthExtensions
- {
- public static IServiceCollection AddLuticateAuth(this IServiceCollection services)
- {
- services.AddLuticatUtils();
-
- services.AddSingleton<LuGroupsController>();
- services.AddSingleton<LuGroupsBusiness>();
- services.AddSingleton<LuGroupsDataAccess>();
-
- services.AddSingleton<LuUsersController>();
-
- services.AddDbContext<LuDatabaseContext>();
-
- return services;
- }
-
- public static IMvcBuilder AddLuticateAuth(this IMvcBuilder builder)
- {
- builder.AddLuticatUtils();
- // builder.AddApplicationPart(typeof(LuController).GetTypeInfo().Assembly)
- // .AddControllersAsServices();
- builder.Services.Configure<MvcOptions>(
- options => options.ModelBinderProviders.Insert(0, new LuOrderByBinderProvider()));
- return builder;
- }
-
- public static IApplicationBuilder UseLuticateAuth(this IApplicationBuilder app)
- {
- app.UseLuticateUtils();
- app.UseMiddleware<LuAuthMiddleware>();
- return app;
- }
-
- public static object GetLuCurrentUser(this HttpContext context)
- {
- return context.GetLuItems()["currentUser"];//TODO
- }
- }
- }
|