Пример #1
0
 public UsersController(
     IBackOfficeUsersRepository usersRepository,
     IBackofficeUserRolesRepository userRolesRepository,
     IUserCacheService userCacheService) : base(usersRepository, userRolesRepository)
 {
     _userCacheService = userCacheService;
 }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            IUserCacheService userCacheService = filterContext.HttpContext.RequestServices.GetService <IUserCacheService>();
            var userId = filterContext.HttpContext.User.Identity.Name;

            if (userId == null)
            {
                filterContext.Result = new UnauthorizedResult();
            }
            else
            {
                var userPair = userCacheService.GetUsersRolePair(userId);

                foreach (var userFeatureAccess in _filters)
                {
                    if (userPair.HasAccessToFeature(userFeatureAccess))
                    {
                        base.OnActionExecuting(filterContext);
                        return;
                    }
                }

                filterContext.Result = new UnauthorizedResult();
            }
        }
 public UpdateUserCurrencyCommandHandler(IUserCacheService userCacheService,
                                         IUserRepository userRepository,
                                         ICurrencyRepository currencyRepository)
 {
     _userCacheService   = userCacheService;
     _userRepository     = userRepository;
     _currencyRepository = currencyRepository;
 }
 public PopulateUserCacheJob(IQueryProcessor queryProcessor,
                             IUserCacheService userCacheService,
                             IBackgroundJobClientService backgroundJobClientService)
 {
     _queryProcessor             = queryProcessor;
     _userCacheService           = userCacheService;
     _backgroundJobClientService = backgroundJobClientService;
 }
 public DeleteTransactionCommandHandler(IUserCacheService userCacheService,
                                        ITransactionRepository transactionRepository,
                                        IUserIdAccesor userIdAccesor)
 {
     _userCacheService      = userCacheService;
     _transactionRepository = transactionRepository;
     _userIdAccesor         = userIdAccesor;
 }
Пример #6
0
 public DeleteAssetCommandHandler(IUserCacheService userCacheService,
                                  IAssetRepository assetRepository,
                                  IUserIdAccesor userIdAccesor)
 {
     _userCacheService = userCacheService;
     _assetRepository  = assetRepository;
     _userIdAccesor    = userIdAccesor;
 }
Пример #7
0
        public RegistrationViewModel(IMvxNavigationService navigation, IPersonDataService personData, IUserCacheService cache)
        {
            _navigation = navigation;
            _personData = personData;
            _cache      = cache;

            SaveAndLoginAsyncCommand = new MvxAsyncCommand(SaveAndLoginAsync, () => CanRegister);
        }
Пример #8
0
        public GetCurrenciesQueryHandler(IUserCacheService cacheService, ICurrencyRepository currencyRepository, IMapper mapper)
            : base(cacheService)
        {
            _currencyRepository = currencyRepository;
            _mapper             = mapper;

            cacheService.SetAbsoluteExpiration(DateTimeOffset.Now.AddDays(5));
        }
 public UpdateGroupCommandHandler(IUserCacheService userCacheService,
                                  IGroupRepository groupRepository,
                                  IUserIdAccesor userIdAccesor)
 {
     _userCacheService = userCacheService;
     _groupRepository  = groupRepository;
     _userIdAccesor    = userIdAccesor;
 }
Пример #10
0
        public HomeViewModel(IMvxNavigationService navigation, IUserCacheService cache)
        {
            _navigation = navigation;
            _cache      = cache;

            LogInAsyncCommand            = new MvxAsyncCommand(LogInAsync, () => CanLogIn);
            ShowAboutUsPageAsyncCommand  = new MvxAsyncCommand(async() => await _navigation.Navigate <AboutUsViewModel>());
            ShowSettingsPageAsyncCommand = new MvxAsyncCommand(async() => await _navigation.Navigate <SettingsViewModel>());
        }
Пример #11
0
 public UserService(IDapperReadOnlyRepository readOnlyRepository,
                    IDapperWriteRepository writeRepository,
                    string secretKey,
                    IUserCacheService userCacheService) : base(readOnlyRepository,
                                                               writeRepository)
 {
     _secretKey        = secretKey;
     _userCacheService = userCacheService;
 }
Пример #12
0
        public LoginViewModel(IMvxNavigationService navigation, IPersonDataService personData, IUserCacheService cache)
        {
            _navigation = navigation;
            _personData = personData;
            _cache      = cache;

            RegisterPersonAsyncCommand = new MvxAsyncCommand(RegisterPersonAsync);
            LoginAsyncCommand          = new MvxAsyncCommand(LoginAsync);
        }
Пример #13
0
        public GameViewModel(IMvxNavigationService navigation, IUserCacheService cache)
        {
            _navigation = navigation;
            _cache      = cache;

            Game = _cache.CachedGame;

            EndCurrentGameAsyncCommand = new MvxAsyncCommand(EndCurrentGameAsync);
        }
Пример #14
0
 public UserRepository(
     IUserCacheService userCacheService,
     ICommandDispatcher commandDispatcher,
     IQueryProcessor queryProcessor
     )
 {
     _userCacheService  = userCacheService;
     _commandDispatcher = commandDispatcher;
     _queryProcessor    = queryProcessor;
 }
Пример #15
0
 public CreateAssetCommandHandler(IUserCacheService userCacheService,
                                  IAssetRepository assetRepository,
                                  IUserIdAccesor userIdAccesor,
                                  IMapper mapper)
 {
     _userCacheService = userCacheService;
     _assetRepository  = assetRepository;
     _userIdAccesor    = userIdAccesor;
     _mapper           = mapper;
 }
        public GetUserInfoQueryHandler(IUserCacheService cacheService,
                                       IUserRepository userRepository,
                                       IMapper mapper)
            : base(cacheService)
        {
            _userRepository = userRepository;
            _mapper         = mapper;

            cacheService.SetAbsoluteExpiration(DateTimeOffset.Now.AddDays(3));
        }
        public GetAllGroupsQueryHandler(IUserCacheService cacheService,
                                        IGroupRepository groupRepository,
                                        IMapper mapper)
            : base(cacheService)
        {
            _groupRepository = groupRepository;
            _mapper          = mapper;

            cacheService.SetAbsoluteExpiration(DateTimeOffset.Now.AddDays(1));
        }
Пример #18
0
 public CreateGroupCommandHandler(IUserCacheService userCacheService,
                                  IGroupRepository groupRepository,
                                  IUserIdAccesor userIdAccesor,
                                  IMapper mapper)
 {
     _mapper           = mapper;
     _userCacheService = userCacheService;
     _groupRepository  = groupRepository;
     _userIdAccesor    = userIdAccesor;
 }
Пример #19
0
        public static Browser MakeTestErrorBrowser <T>(
            IUserService fakeUserService               = null,
            IUserCacheService fakeUserCacheService     = null,
            IApplicationService fakeApplicationService = null,
            IPasswordService fakePasswordService       = null,
            ICryptoService fakeCryptoService           = null) where T : INancyModule
        {
            var errorService = new ErrorService();

            return(MakeTestBrowser <T>(fakeUserService, fakeUserCacheService, fakeApplicationService, fakePasswordService, fakeCryptoService, errorService));
        }
Пример #20
0
        public AccountViewModel(IMvxNavigationService navigation, IUserCacheService cache)
        {
            _navigation = navigation;
            _cache      = cache;

            LogInAsyncCommand = new MvxAsyncCommand(LogInAsync, () => CanLogIn);

            ShowStatsPageAsyncCommand         = new MvxAsyncCommand(ShowStatsPageAsync, () => CanSeeStats);
            ShowGameListPageAsyncCommand      = new MvxAsyncCommand(async() => await _navigation.Navigate <GameListViewModel>());
            ShowNotificationsPageAsyncCommand = new MvxAsyncCommand(async() => await _navigation.Navigate <NotificationsViewModel>());
        }
Пример #21
0
        public GameListViewModel(IMvxNavigationService navigation, IGameDataService gameData, IUserCacheService cahche)
        {
            _navigation = navigation;
            _gameData   = gameData;
            _cache      = cahche;

            GamesList = new ObservableCollection <GameModel>(_cache.CachedUser.AvailableGames);

            ShowGamePageAsyncCommand = new MvxAsyncCommand(async() => await _navigation.Navigate <GameViewModel, GameModel>(SelectedGame));
            AddGameCommand           = new MvxCommand(AddGame, () => CanAddGame);
        }
Пример #22
0
        public GetAssetQueryHandler(IUserCacheService cacheService,
                                    IAssetRepository assetRepository,
                                    IMapper mapper,
                                    IUserIdAccesor userIdAccesor)
            : base(cacheService)
        {
            _assetRepository = assetRepository;
            _mapper          = mapper;
            _userIdAccesor   = userIdAccesor;

            cacheService.SetAbsoluteExpiration(DateTimeOffset.Now.AddDays(1));
        }
Пример #23
0
 public HomeController(IWorkContext workContext,
                       IUserCacheService userCacheService,
                       IUserService <UserEntity> userService,
                       IMenuService <MenuEntity> menuService,
                       ISettingService settingService)
     : base(workContext)
 {
     this.userCacheService = userCacheService;
     this.userService      = userService;
     this.menuService      = menuService;
     this.settingService   = settingService;
 }
Пример #24
0
 public MenuController(IWorkContext workContext,
                       IUserCacheService userCacheService,
                       IMenuService <MenuEntity> menuService,
                       IMenuPurviewCodeService <MenuPurviewCodeEntity> menuPurviewCodeService,
                       IUserService <UserEntity> userService)
     : base(workContext)
 {
     this.userCacheService       = userCacheService;
     this.menuService            = menuService;
     this.menuPurviewCodeService = menuPurviewCodeService;
     this.userService            = userService;
 }
 /// <summary>
 /// Creates a new BearerTokenUserProvider instance with the given logger instance.
 /// </summary>
 /// <param name="cacheService">The user cache service.</param>
 /// <param name="permissionService">The permission store.</param>
 /// <param name="userService">The user service.</param>
 public BearerTokenUserProvider(
     IUserService userService,
     IUserCacheService cacheService,
     IPermissionService permissionService)
 {
     Contract.Requires(cacheService != null, "The cache service must not be null.");
     Contract.Requires(permissionService != null, "The permissionStore must not be null.");
     Contract.Requires(userService != null, "The user service must not be null.");
     this.cacheService      = cacheService;
     this.permissionService = permissionService;
     this.userService       = userService;
 }
Пример #26
0
 public LoginController(IWorkContext workContext,
                        IVerifyCode verifyCode,
                        IWebHelper webHelper,
                        IUserCacheService userCacheService,
                        Messages messages,
                        IUserService <UserEntity> userService)
 {
     this.workContext      = workContext;
     this.verifyCode       = verifyCode;
     this.webHelper        = webHelper;
     this.userCacheService = userCacheService;
     this.messages         = messages;
     this.userService      = userService;
 }
        public GetGroupTotalQueryHandler(IUserCacheService cacheService,
                                         IGroupRepository groupRepository,
                                         ITransactionRepository transactionRepository,
                                         ICurrencyRepository currencyRepository,
                                         IForexService forexService)
            : base(cacheService)
        {
            _groupRepository       = groupRepository;
            _transactionRepository = transactionRepository;
            _currencyRepository    = currencyRepository;
            _forexService          = forexService;

            cacheService.SetSlidingExpiration(TimeSpan.FromMinutes(10));
        }
Пример #28
0
 public CrmService(IServiceScopeFactory serviceScopeFactory) : base(serviceScopeFactory)
 {
     _crmStatusCacheService = serviceScopeFactory.CreateScope()
                              .ServiceProvider.GetService <ICrmStatusCacheService>();
     _crmPriorityCacheService = serviceScopeFactory.CreateScope()
                                .ServiceProvider.GetService <ICrmPriorityCacheService>();
     _customerSourceCacheService = serviceScopeFactory.CreateScope()
                                   .ServiceProvider.GetService <ICustomerSourceCacheService>();
     _productGroupCacheService = serviceScopeFactory.CreateScope()
                                 .ServiceProvider.GetService <IProductGroupCacheService>();
     _crmTypeCacheService = serviceScopeFactory.CreateScope()
                            .ServiceProvider.GetService <ICrmTypeCacheService>();
     _userCacheService = serviceScopeFactory.CreateScope()
                         .ServiceProvider.GetService <IUserCacheService>();
 }
        public GetAssetsTotalQueryHandler(IUserCacheService cacheService,
                                          IAssetRepository assetRepository,
                                          ITransactionRepository transactionRepository,
                                          ICurrencyRepository currencyRepository,
                                          IForexService forexService,
                                          IMapper mapper)
            : base(cacheService)
        {
            _assetRepository       = assetRepository;
            _transactionRepository = transactionRepository;
            _currencyRepository    = currencyRepository;
            _forexService          = forexService;
            _mapper = mapper;

            cacheService.SetSlidingExpiration(TimeSpan.FromMinutes(10));
        }
Пример #30
0
 public CreateTransactionCommandHandler(IUserCacheService userCacheService,
                                        ITransactionRepository transactionRepository,
                                        IAssetRepository assetRepository,
                                        IGroupRepository groupRepository,
                                        ICurrencyRepository currencyRepository,
                                        IUserIdAccesor userIdAccesor,
                                        IMapper mapper)
 {
     _userCacheService      = userCacheService;
     _transactionRepository = transactionRepository;
     _assetRepository       = assetRepository;
     _groupRepository       = groupRepository;
     _currencyRepository    = currencyRepository;
     _userIdAccesor         = userIdAccesor;
     _mapper = mapper;
 }
Пример #31
0
        public UserModule(IUserService userService, IErrorService error, IPasswordService passwordService, IUserCacheService userCacheService)
            : base("/user")
        {
            Post["/create"] = _ =>
            {
                if (Params.AreMissing("UserName", "Email")) return error.MissingParameters(Response);
                if (userService.GetUserByName(Params.UserName)!=null) return error.UserNameTaken(Response);
                if (!Params.Email.IsEmail()) return error.InvalidParameters(Response);
                var password = userService.CreateUser(Params.UserName, Params.Email);
                return (string.IsNullOrWhiteSpace(password)) ? error.InvalidParameters(Response) : Response.AsJson(new { Password = password });
            };

            Post["/validate"] = _ =>
            {
                if (Params.AreMissing("UserName", "Password")) return error.MissingParameters(Response);
                var user = userService.GetUserByName(Params.UserName);
                if (user == null || !passwordService.IsPasswordValid(user, Params.Password)) return error.NoUserForCredentials(Response);
                var key = userCacheService.Add(user);
                return (key == null) ? error.InvalidParameters(Response) : Response.AsJson(new { ThumbKey = key });
            };

            Post["/get"] = _ =>
            {
                if (Params.AreMissing("ThumbKey")) return error.MissingParameters(Response);
                if (!Params.ThumbKey.IsGuid()) return error.InvalidParameters(Response);
                var user = userCacheService.GetUser(Params.ThumbKey);
                return (user == null) ? error.NoUserForThumbkey(Response) : Response.AsJson(new { User = new { Id = user.Id, UserName = user.UserName, Email = user.Email } });
            };

            Post["/validate/thumbkey"] = _ =>
            {
                if (Params.AreMissing("ThumbKey")) return error.MissingParameters(Response);
                if (!Params.ThumbKey.IsGuid()) return error.InvalidParameters(Response);
                var isValid = userCacheService.Validate(Params.ThumbKey);
                return !isValid ? error.NoUserForThumbkey(Response) : HttpStatusCode.OK;
            };

            Post["/validate/name"] = _ =>
            {
                if (Params.AreMissing("UserName")) return error.MissingParameters(Response);
                var isValid = userService.GetUserByName(Params.UserName)==null;
                return !isValid ? error.UserNameTaken(Response) : HttpStatusCode.OK;
            };

            Post["/reset/password"] = _ =>
            {
                if (Params.AreMissing("UserName", "Password")) return error.MissingParameters(Response);
                var user = userService.GetUserByName(Params.UserName);
                if (user == null || !passwordService.IsPasswordValid(user, Params.Password)) return error.NoUserForCredentials(Response);
                var password = userService.ResetPassword(user);
                return (password == null) ? error.InvalidParameters(Response) : Response.AsJson(new { Password = password });
            };

            Post["/forgot-password/request"] = _ =>
            {
                if (Params.AreMissing("UserName", "Email")) return error.MissingParameters(Response);
                if (!Params.Email.IsEmail()) return error.InvalidParameters(Response);
                var user = userService.GetUserByName(Params.UserName);
                if (user == null) return error.NoUserForCredentials(Response);
                if (user.Email != Params.Email) return error.NoUserForEmail(Response);
                var token = userService.ForgotPasswordRequest(user);
                return (token == null) ? error.InvalidParameters(Response) : Response.AsJson(new { Token = token });
            };

            Post["/forgot-password/reset"] = _ =>
            {
                if (Params.AreMissing("UserName", "Token")) return error.MissingParameters(Response);
                if (!Params.Token.IsGuid()) return error.InvalidParameters(Response);
                var user = userService.GetUserByName(Params.UserName);
                if (user == null || !passwordService.IsForgotPasswordTokenValid(user, Params.Token)) return error.InvalidForgotPasswordToken(Response);
                var password = userService.ForgotPasswordReset(user);
                return (password == null) ? error.InvalidParameters(Response) : Response.AsJson(new { Password = password });
            };

            Post["/logout"] = _ =>
            {
                if (Params.AreMissing("ThumbKey")) return error.MissingParameters(Response);
                if (!Params.ThumbKey.IsGuid()) return error.InvalidParameters(Response);
                var success = userCacheService.Remove(Params.ThumbKey);
                return !success ? error.NoUserForThumbkey(Response) : HttpStatusCode.OK;
            };
        }