示例#1
0
        public AppContext()
        {
            string storePath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "store.db");

            Type tEvent     = typeof(IEvent);
            Type tTO        = typeof(ITransferObject);
            var  allTypes   = System.Reflection.Assembly.GetExecutingAssembly().GetTypes();
            var  knownTypes = allTypes
                              .Where(t => !t.IsAbstract)
                              .Where(t => t.IsClass || t.IsValueType)
                              .Where(t => tEvent.IsAssignableFrom(t) || tTO.IsAssignableFrom(t)).ToArray();

            JSONFileEventStore store = new JSONFileEventStore(storePath, knownTypes);

            Repository = new Repository(store);
            var bus = MessageBus.Instance;

            AccountProjection = new AccountProjection(store, bus);
            AccountProjection.Init();
            AccountHandler = new Account.Handler(Repository, bus);

            GameProjection = new GameProjection(store, bus);
            GameProjection.Init();
            GameHandler = new BC.Game.Game.Handler(Repository, bus);

            FriendshipProjection = new FriendshipProjection(store, bus);
            FriendshipProjection.Init();
            FriendshipHandler = new Friendship.Handler(Repository, bus);
            //autologout ohne events
            AccountProjection.LogoutAllAccounts();

            GameProjection.CloseGamesAfterChallengeExpires();
        }
示例#2
0
 public UserController(AccountEntry accountEntry, AccountProjection accountProjection, BC.Game.GameProjection gameProjection, FriendshipProjection friendshipProjection)
 {
     AccountEntry         = accountEntry;
     AccountProjection    = accountProjection;
     GameProjection       = gameProjection;
     FriendshipProjection = friendshipProjection;
 }
示例#3
0
 public SettingsController(AccountEntry accountEntry, AccountProjection accountProjection)
 {
     AccountEntry      = accountEntry;
     AccountProjection = accountProjection;
     CurrentContent    = RenderPersonalInfo;
     Icon = accountEntry.Icon;
 }
示例#4
0
 public FriendshipController(AccountEntry accountEntry, AccountProjection accountProjection, ChessgameProjection gameProjection,
                             FriendshipProjection friendshipProjection, RootController rootController)
 {
     AccountEntry         = accountEntry;
     AccountProjection    = accountProjection;
     GameProjection       = gameProjection;
     FriendshipProjection = friendshipProjection;
     RenderCurrentcontent = RenderOverview;
 }
示例#5
0
 public static IEnumerable <ValidationResult> ValidateUser(AccountProjection user, string userPassword)
 {
     if (user == null || !PasswordHash.ValidatePassword(userPassword, user.Password))
     {
         yield return(new ValidationResult("The user name or password provided is incorrect."));
     }
     else
     {
         if (!user.Roles.Any())
         {
             yield return(new ValidationResult("User has no one role."));
         }
     }
 }
示例#6
0
        public void Retrieve_Success()
        {
            const string password           = "******";
            const string token              = "sample_token";
            var          logonMock          = new Mock <ILogonManager>();
            var          ctrlMock           = ControllerTestFactory.CreateMock(new TokenController(logonMock.Object));
            var          userRepositoryMock = ctrlMock.MockRepository(r => r.Users);

            var accountProj = new AccountProjection {
                Password = PasswordHash.HashPassword(password)
            };

            userRepositoryMock.Setup(x => x.GetAccountByLoginOrNull(It.IsAny <string>()))
            .Returns(accountProj);
            logonMock.Setup(x => x.GenerateToken(It.IsAny <LoggedClaims>(), It.IsAny <DateTime>())).Returns(token);

            var res = ctrlMock.Ctrl.Retrieve(new TokenRetrieveArgs {
                Password = password
            });

            Assert.AreEqual(true, res.ReturnValue.IsAuthenticated);
            Assert.AreEqual(token, res.ReturnValue.Token);
        }
 public SolitaireController(SolitaireProjection solitaireProjection, AccountProjection accountProjection, AccountID accountID)
 {
     SolitaireProjection = solitaireProjection;
     AccountProjection   = accountProjection;
     AccountID           = accountID;
 }
示例#8
0
 public LoggedClaims(AccountProjection account)
     : this(account.Id, account.Login, account.Roles)
 {
 }
示例#9
0
 protected override IEnumerable <ValidationResult> Validate(IUnitOfWork unitOfWork, ILoggedUserAccessor loggedUser, ValidationContext validationContext)
 {
     AccountAfterValidation = unitOfWork.Users.GetAccountByLoginOrNull(UserName);
     return(ValidateUser(AccountAfterValidation, Password));
 }
示例#10
0
 public LoginController(AccountProjection accountProjection)
 {
     AccountProjection = accountProjection;
 }
 public LoginController(AccountProjection accountProjection)
 {
     AccountProjection = accountProjection;
     CurrentContent    = RenderLogin;
 }