Example #1
0
        private void ApplicationSetup()
        {
            var kernel = NinjectWebCommon.GetKernel();
            var setup  = kernel.Get <ISetup>();

            setup.Start();
        }
Example #2
0
 public void Configuration(IAppBuilder app)
 {
     Kernel = NinjectWebCommon.GetKernel();
     ConfigureAuth(app);
     app.MapSignalR();
     ApplicationSetup();
 }
Example #3
0
        private bool CheckAuthentication()
        {
            // TODO: Swap out the service locator with something else
            var kernel     = NinjectWebCommon.GetKernel();
            var authHelper = new AuthenticationHelper(kernel.Get <ISettingsService <NzbDashSettingsDto> >());

            return(authHelper.IsAuthenticated());
        }
Example #4
0
 protected void Application_PostAuthenticateRequest()
 {
     if (Request.IsAuthenticated)
     {
         string login          = Context.User.Identity.Name;
         var    userRepository = NinjectWebCommon.GetKernel().GetService(typeof(IUserRepository)) as IUserRepository;
         Context.User = userRepository.FindByLogin(login);
     }
 }
Example #5
0
        public UserTests()
        {
            var kernel = NinjectWebCommon.GetKernel();

            this.logic = kernel.Get <IUserLogic>();

            this.pageInfo = new PageInfo
            {
                PageNumber = 0,
                PageSize   = Int32.MaxValue / 2,
            };
        }
Example #6
0
        public AlbumTests()
        {
            var kernel = NinjectWebCommon.GetKernel();

            this.logic = kernel.Get <IAlbumLogic>();

            this.pageInfo = new PageInfo
            {
                PageNumber = 0,
                PageSize   = int.MaxValue / 2,
            };
        }
Example #7
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            // TODO: Swap out the service locator with something else
            var kernel     = NinjectWebCommon.GetKernel();
            var authHelper = new AuthenticationHelper(kernel.Get <ISettingsService <NzbDashSettingsDto> >());

            var shouldBeAuth = authHelper.IsAuthenticated();

            if (!User.Identity.IsAuthenticated && shouldBeAuth)
            {
                filterContext.Result = RedirectToAction("Login", "Account");
                return;
            }

            base.OnActionExecuting(filterContext);
        }
        public static void Register(HttpConfiguration config)
        {
            var kernel = NinjectWebCommon.GetKernel();

            // Web API configuration and services
            config.Filters.Add(kernel.Get <UnhandledExceptionFilterAttribute>());
            config.MessageHandlers.Add(kernel.Get <TracingHandler>());

            config.Formatters.Clear();
            var jsonFormatter = new JsonMediaTypeFormatter();

            jsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json"));
            config.Formatters.Add(jsonFormatter);

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
        }