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(); }
public UserController(AccountEntry accountEntry, AccountProjection accountProjection, BC.Game.GameProjection gameProjection, FriendshipProjection friendshipProjection) { AccountEntry = accountEntry; AccountProjection = accountProjection; GameProjection = gameProjection; FriendshipProjection = friendshipProjection; }
public SettingsController(AccountEntry accountEntry, AccountProjection accountProjection) { AccountEntry = accountEntry; AccountProjection = accountProjection; CurrentContent = RenderPersonalInfo; Icon = accountEntry.Icon; }
public FriendshipController(AccountEntry accountEntry, AccountProjection accountProjection, ChessgameProjection gameProjection, FriendshipProjection friendshipProjection, RootController rootController) { AccountEntry = accountEntry; AccountProjection = accountProjection; GameProjection = gameProjection; FriendshipProjection = friendshipProjection; RenderCurrentcontent = RenderOverview; }
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.")); } } }
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; }
public LoggedClaims(AccountProjection account) : this(account.Id, account.Login, account.Roles) { }
protected override IEnumerable <ValidationResult> Validate(IUnitOfWork unitOfWork, ILoggedUserAccessor loggedUser, ValidationContext validationContext) { AccountAfterValidation = unitOfWork.Users.GetAccountByLoginOrNull(UserName); return(ValidateUser(AccountAfterValidation, Password)); }
public LoginController(AccountProjection accountProjection) { AccountProjection = accountProjection; }
public LoginController(AccountProjection accountProjection) { AccountProjection = accountProjection; CurrentContent = RenderLogin; }