public AccountController( HttpContextWrapper httpContext, HttpResponseWrapper httpResponse) { _context = httpContext; _response = httpResponse; _authenticationManager = _context.GetOwinContext().Authentication; _userManager = _context.GetOwinContext().GetUserManager <ApplicationUserManager>(); }
public override void Load() { this.Bind <IForumDbContext>().To <ForumDbContext>().InRequestScope(); this.Bind(typeof(IRepository <>)).To(typeof(EfRepository <>)); this.Bind <IUowData>().To <UowData>(); this.Bind <IUserStore <ApplicationUser> >().To <ApplicationUserStore>(); this.Bind <UserManager <ApplicationUser> >().ToSelf(); this.Bind <HttpContextBase>().ToMethod(ctx => new HttpContextWrapper(HttpContext.Current)).InTransientScope(); this.Bind <ApplicationSignInManager>().ToMethod((context) => { var cbase = new HttpContextWrapper(HttpContext.Current); return(cbase.GetOwinContext().Get <ApplicationSignInManager>()); }); this.Bind <ApplicationUserManager>().ToSelf(); this.Bind <IMappingService>().To <MappingService>(); this.Bind <IPagerViewModel>().To <PagerViewModel>(); this.Bind <IAjaxPagerViewModel>().To <AjaxPagerViewModel>(); this.Bind <IForumThreadViewModel>().To <ForumThreadViewModel>(); this.Bind <IHomePageViewModel>().To <HomePageViewModel>(); this.Bind <IPagerViewModelFactory>().ToFactory().InRequestScope(); this.Bind <IViewModelFactory>().ToFactory().InRequestScope(); }
/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { kernel.Bind <PMISEntities>().ToSelf().InRequestScope(); kernel.Bind <IUnitOfWork>().To <UnitOfWork>(); kernel.Bind <IAppointmentServices>().To <AppointmentServices>(); kernel.Bind <IPatientServices>().To <PatientServices>(); kernel.Bind <IPatientRecordServices>().To <PatientRecordServices>(); kernel.Bind <IUserPhysicianService>().To <UserPhysicianService>(); kernel.Bind <IPrescriptionServices>().To <PrescriptionServices>(); kernel.Bind <IPhyPrescriptionServices>().To <PhyPrescriptionServices>(); kernel.Bind <ApplicationDbContext>().ToSelf(); kernel.Bind <IUserStore <ApplicationUser> >().To <UserStore <ApplicationUser> >().WithConstructorArgument("context", kernel.Get <ApplicationDbContext>()); kernel.Bind <UserManager <ApplicationUser> >().ToSelf(); kernel.Bind <HttpContextBase>().ToMethod(ctx => new HttpContextWrapper(HttpContext.Current)) .InTransientScope(); kernel.Bind <ApplicationSignInManager>().ToMethod((context) => { var cbase = new HttpContextWrapper(HttpContext.Current); return(cbase.GetOwinContext().Get <ApplicationSignInManager>()); }); kernel.Bind <ApplicationUserManager>().ToSelf(); }
private static IOwinContext GetOwinContext() { var cbase = new HttpContextWrapper(HttpContext.Current); var owinCtx = cbase.GetOwinContext(); if (owinCtx == null) { throw new ArgumentNullException(nameof(owinCtx)); } return(owinCtx); }
/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { kernel.Bind(typeof(IProductRepository)).To(typeof(ProductRepository)); kernel.Bind <IUserStore <ApplicationUser> >().To <UserStore <ApplicationUser> >(); kernel.Bind <UserManager <ApplicationUser> >().ToSelf(); kernel.Bind <IAuthenticationManager>().ToMethod(context => { var contextBase = new HttpContextWrapper(HttpContext.Current); return(contextBase.GetOwinContext().Authentication); }); }
public override void Load() { Bind <ApplicationUserManager>().ToMethod(GetOwin.GetOwinInjection <ApplicationUserManager>); Bind <ApplicationSignInManager>().ToMethod(GetOwin.GetOwinInjection <ApplicationSignInManager>); Bind <ApplicationRoleManager>().ToMethod(GetOwin.GetOwinInjection <ApplicationRoleManager>); Bind <IAuthenticationManager>().ToMethod(context => { var contextBase = new HttpContextWrapper(HttpContext.Current); return(contextBase.GetOwinContext().Authentication); }); }
/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { kernel.Bind <IService <TagDTO> >().To <TagService>(); kernel.Bind <IPhotoService>().To <PhotoService>(); kernel.Bind <IService <LikeDTO> >().To <LikeService>(); kernel.Bind <IProfileService>().To <ProfileService>(); kernel.Bind <IUserService>().To <UserService>(); kernel.Bind <IAuthenticationManager>().ToMethod(context => { var contextBase = new HttpContextWrapper(HttpContext.Current); return(contextBase.GetOwinContext().Authentication); }); }
/// <summary> /// Loads modules and registers services for the application. If a new module is added, this method should be updated. /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { kernel.Bind <ITimeProvider>().To <TimeProvider>().InRequestScope(); kernel.Bind <IStudiesDbContext, IIdentityDbContext <ApplicationUser>, DbContext>() .To <UXRDbContext>() .InRequestScope(); kernel.Bind <ICommandHandlerResolver>() .To <NinjectCommandHandlerResolver>() .InSingletonScope(); kernel.Bind <IUserStore <ApplicationUser> >().ToMethod((context) => { return(new UserStore <ApplicationUser>(kernel.Get <DbContext>())); }).InRequestScope(); kernel.Bind <ApplicationUserManager>().ToMethod((context) => { var options = context.Kernel.Get <IdentityFactoryOptions <ApplicationUserManager> >(); options.DataProtectionProvider = options.DataProtectionProvider ?? new DpapiDataProtectionProvider("UXR"); var userStore = context.Kernel.Get <IUserStore <ApplicationUser> >(); return(ApplicationUserManager.Create(options, userStore)); }).InRequestScope(); kernel.Bind <IAuthenticationManager>().ToMethod(context => { var contextBase = new HttpContextWrapper(HttpContext.Current); return(contextBase.GetOwinContext().Authentication); }).InRequestScope(); kernel.Bind <ApplicationSignInManager>().ToMethod((context) => { var options = context.Kernel.Get <IdentityFactoryOptions <ApplicationSignInManager> >(); var userManager = context.Kernel.Get <ApplicationUserManager>(); var authenticatioManager = context.Kernel.Get <IAuthenticationManager>(); return(ApplicationSignInManager.Create(options, userManager, authenticatioManager)); }).InRequestScope(); kernel.Bind <CommandDispatcher>().ToSelf().InSingletonScope(); kernel.Load ( new UXR.Modules.IdentityDbModule(), new UXR.Studies.Modules.StudiesDbModule(), new UXR.Studies.Modules.CommandHandlersModule(), new UXR.Studies.Modules.FilesModule() ); }
/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { kernel.Bind <IUnitOfWork>().To <UnitOfWork>().InRequestScope(); kernel.Bind(typeof(IRepository <>)).To(typeof(Repository <>)); kernel.Bind <ApplicationUserManager>().ToMethod(GetOwinInjection <ApplicationUserManager>); kernel.Bind <ApplicationSignInManager>().ToMethod(GetOwinInjection <ApplicationSignInManager>); kernel.Bind <IAuthenticationManager>().ToMethod(context => { var contextBase = new HttpContextWrapper(HttpContext.Current); return(contextBase.GetOwinContext().Authentication); }); }
private static void AddApplicationUserManagerBindings(IKernel kernel) { kernel.Bind <ApplicationDbContext>().ToSelf().InRequestScope(); kernel.Bind <IUserStore <ApplicationUser> >() .To <UserStore <ApplicationUser> >() .WithConstructorArgument("context", kernel.Get <ApplicationDbContext>()); ; kernel.Bind <UserManager <ApplicationUser> >().ToSelf(); kernel.Bind <HttpContextBase>().ToMethod(ctx => new HttpContextWrapper(HttpContext.Current)).InTransientScope(); kernel.Bind <ApplicationSignInManager>().ToMethod((context) => { var cbase = new HttpContextWrapper(HttpContext.Current); return(cbase.GetOwinContext().Get <ApplicationSignInManager>()); }); kernel.Bind <IAuthenticationManager>().ToMethod(c => HttpContext.Current.GetOwinContext().Authentication).InRequestScope(); kernel.Bind <ApplicationUserManager>().ToMethod(c => HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>()).InRequestScope(); }
/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { kernel.Bind <IAccountService>().To <AccountService>(); kernel.Bind <IManageAccountService>().To <ManageAccountService>(); kernel.Bind <IGameService>().To <GameService>(); kernel.Bind <IAdminHomeService>().To <AdminHomeService>(); kernel.Bind <DbContext>().To <PlaySchoolContext>(); kernel.Bind <IUserStore <ApplicationUser> >().To <UserStore <ApplicationUser> > (); kernel.Bind <UserManager <ApplicationUser> >().ToSelf(); kernel.Bind <HttpContextBase>().ToMethod(ctx => new HttpContextWrapper(HttpContext.Current)).InTransientScope(); kernel.Bind <ApplicationSignInManager>().ToMethod((context) => { var cbase = new HttpContextWrapper(HttpContext.Current); return(cbase.GetOwinContext().Get <ApplicationSignInManager>()); }); kernel.Bind <ApplicationUserManager>().ToSelf(); //kernel.Bind<PlaySchoolContext>().To<PlaySchoolContext>(); }
private static IList <Role> GetLtiRolesForUser(ApplicationUser user) { var httpContext = new HttpContextWrapper(HttpContext.Current); var roleManager = httpContext.GetOwinContext().Get <ApplicationRoleManager>(); var roles = new List <Role>(); foreach (var identityRole in user.Roles.Select(role => roleManager.FindById(role.RoleId))) { if (identityRole.Name.Equals(UserRoles.StudentRole)) { roles.Add(Role.Learner); } if (identityRole.Name.Equals(UserRoles.TeacherRole)) { roles.Add(Role.Instructor); } } return(roles); }
public override void Load() { this.Rebind <IApplicationSignInManager>() .ToMethod((context) => { var cbase = new HttpContextWrapper(HttpContext.Current); var owinCtx = cbase.GetOwinContext(); ThrowIfNull(owinCtx); return(owinCtx.Get <IApplicationSignInManager>()); }); this.Rebind <IApplicationUserManager>() .ToMethod((context) => { var cbase = new HttpContextWrapper(HttpContext.Current); var owinCtx = cbase.GetOwinContext(); ThrowIfNull(owinCtx); return(owinCtx.Get <IApplicationUserManager>()); }); }
/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { kernel.Bind <IUserStore <ApplicationUser> >().To <UserStore <ApplicationUser> >(); kernel.Bind <UserManager <ApplicationUser> >().ToSelf(); kernel.Bind <HttpContextBase>().ToMethod(ctx => new HttpContextWrapper(HttpContext.Current)).InTransientScope(); kernel.Bind <ApplicationSignInManager>().ToMethod((context) => { var cbase = new HttpContextWrapper(HttpContext.Current); return(cbase.GetOwinContext().Get <ApplicationSignInManager>()); }); kernel.Bind <ApplicationUserManager>().ToSelf(); // Entities kernel.Bind(typeof(IGenericRepository <Client>)).To(typeof(GenericRepository <Client>)); kernel.Bind(typeof(IGenericRepository <Collection>)).To(typeof(GenericRepository <Collection>)); kernel.Bind(typeof(IGenericRepository <Sale>)).To(typeof(GenericRepository <Sale>)); kernel.Bind(typeof(IGenericRepository <Stock>)).To(typeof(GenericRepository <Stock>)); kernel.Bind(typeof(IGenericRepository <StockGroup>)).To(typeof(GenericRepository <StockGroup>)); kernel.Bind(typeof(IGenericRepository <UnitSize>)).To(typeof(GenericRepository <UnitSize>)); }
/// <summary> /// Dependency injection for ASP.Net Identity /// </summary> /// <typeparam name="T"></typeparam> /// <param name="context"></param> /// <returns></returns> public static T GetOwinInjection <T>(IContext context) where T : class { var contextBase = new HttpContextWrapper(HttpContext.Current); return(contextBase.GetOwinContext().Get <T>()); }
GetOpenAuthProviders() { return(_context.GetOwinContext().Authentication .GetExternalAuthenticationTypes()); }