public void SetUp() { _collector = Substitute.For<IItemCollector>(); _scheduler = Substitute.For<IScheduler>(); _loginModel = Substitute.For<ILoginModel>(); _uut = new ScheduledShoppingListModel(_collector, _scheduler, _loginModel); }
public RuleResult IsAuthenticated(ILoginModel model) { user user = CurrentUser.CurrentClient = GetFirstUser(model); return user == null ? RuleResult.Fail : RuleResult.Success; }
public LoginPresenter(ILoginView view) { loginView = view; loginModel = new LoginModel(); loginView.Login += LoginView_Login; }
public void SetUp() { _model = Substitute.For<ILoginModel>(); _messageService = Substitute.For<IMessageBoxService>(); _wos = Substitute.For<IWindowOpeningService>(); _uut = new LoginViewModel(_model, _messageService, _wos); }
private user GetFirstUser(ILoginModel model) { string pass = Encryptor.Encrypt(model.PassWord); return _userRepository.Query() .FirstOrDefault(us => us.Name == model.Login && us.Password == pass); }
public static bool Login(string userName, string password) { LoginModel = loginManager.Login(userName, password); PublishAuthenticationEvent(LoginModel); return(loginManager.IsLogin); }
public LoginPresenter(ILoginView loginView, ILoginModel loginModel, ISession session) { _session = session; _loginView = loginView; _loginModel = loginModel; _loginView.LoginClicked += LoginView_LoginClicked; _loginView.CancelClicked += LoginView_CancelClicked; }
public StartViewModel(ILoginModel loginBack) { _loginBack = loginBack; SavedUsers = new ObservableCollection <TokenViewModel>(); NewLoginButton_Click = new DelegateCommand( SwitchViewModels, () => LoginAllowed ); }
public LoginViewModel(ILoginModel model, IToastService toastService, ILocalizationService localizationService) { IsLoginPanelShow = true; IsRegistrationPanelShow = false; IsLoginProgressShow = false; _model = model; _toastService = toastService; _localizationService = localizationService; Currencies = new ObservableCollection <Currency>(); }
/// <summary> /// Sets up the foodplan model with constructorinjection of all its properties /// </summary> /// <param name="foodplanCollector"></param> /// <param name="shoppingListModel"></param> /// <param name="recipeListModel"></param> /// <param name="loginModel"></param> /// <param name="msgBoxService"></param> public FoodplanModel(IFoodplanCollector foodplanCollector, IShoppingListModel shoppingListModel, IRecipeListModel recipeListModel, ILoginModel loginModel, IMessageBoxService msgBoxService) { _foodplanCollector = foodplanCollector; _shoppingListModel = shoppingListModel; _recipeListModel = recipeListModel; _loginModel = loginModel; _msgBoxService = msgBoxService; _foodPlan = new Foodplan(); }
/// <summary> /// Sets up the foodplan model with constructorinjection of all its properties /// </summary> /// <param name="foodplanCollector"></param> /// <param name="shoppingListModel"></param> /// <param name="recipeListModel"></param> /// <param name="loginModel"></param> /// <param name="msgBoxService"></param> public FoodplanModel(IFoodplanCollector foodplanCollector, IShoppingListModel shoppingListModel, IRecipeListModel recipeListModel, ILoginModel loginModel, IMessageBoxService msgBoxService) { _foodplanCollector = foodplanCollector; _shoppingListModel = shoppingListModel; _recipeListModel = recipeListModel; _loginModel = loginModel; _msgBoxService = msgBoxService; _foodPlan = new Foodplan(); }
public void SetUp() { //Setup mocks _collector = Substitute.For <IUserCollector>(); _messageService = Substitute.For <IMessageBoxService>(); _wos = Substitute.For <IWindowOpeningService>(); //Setup reals _model = new LoginModel(_collector); _sut = new LoginViewModel(_model, _messageService, _wos); }
public void SetUp() { //Setup mocks _collector = Substitute.For<IUserCollector>(); _messageService = Substitute.For<IMessageBoxService>(); _wos = Substitute.For<IWindowOpeningService>(); //Setup reals _model = new LoginModel(_collector); _sut = new LoginViewModel(_model, _messageService, _wos); }
public LoginViewModel(ILoginModel loginBack) { _loginBack = loginBack; LoginButton_Click = new DelegateCommand <object>( AttemptLogin, o => !string.IsNullOrEmpty(Username) && !LoginInProgress && ServerSet == ServerState.Connected ); Server_Connect = new DelegateCommand( AttemptConnection, () => !string.IsNullOrEmpty(ServerUrl) && ServerSet != ServerState.Connecting); }
/// <summary> /// Sets up the LoginViewModel using constructor injection /// </summary> /// <param name="model"></param> /// <param name="messageService"></param> /// <param name="wos"></param> public LoginViewModel(ILoginModel model, IMessageBoxService messageService, IWindowOpeningService wos) { if (model == null) throw new ArgumentNullException(); if (messageService == null) throw new ArgumentNullException(); if (wos == null) throw new ArgumentNullException(); _model = model; _messageService = messageService; _wos = wos; UserName = ""; Password = ""; }
public void Setup() { _foodplanCollector = Substitute.For <IFoodplanCollector>(); _shoppingListModel = Substitute.For <IShoppingListModel>(); _recipeListModel = Substitute.For <IRecipeListModel>(); _loginModel = Substitute.For <ILoginModel>(); _msgBoxService = Substitute.For <IMessageBoxService>(); _uut = new FoodplanModel(_foodplanCollector, _shoppingListModel, _recipeListModel, _loginModel, _msgBoxService); _uut.Foodplan = new Foodplan() { RecipeList = new List <Tuple <Recipe, DateTime> >() }; }
/// <summary> /// Sets up the ScheduledShoppingListModel with constructorinjection /// </summary> /// <param name="itemCollector"></param> /// <param name="scheduler"></param> /// <param name="loginModel"></param> public ScheduledShoppingListModel(IItemCollector itemCollector, IScheduler scheduler, ILoginModel loginModel) { if (itemCollector == null) throw new ArgumentNullException(); if (scheduler == null) throw new ArgumentNullException(); _shoppingList = new List<Item>(); _itemCollector = itemCollector; _scheduler = scheduler; _loginModel = loginModel; UpdateShoppingList(); _scheduler.Tick += UpdateShoppingList; _scheduler.Start(); }
private void OnAuthenticated(ILoginModel loginModel) { if (loginModel == null || string.IsNullOrEmpty(loginModel.Token)) { GroupItems = null; } else { GroupItems = _menuDataService.GetMenus(); } //Publish the authorized feature retrieved event. _eventAggregator.GetEvent <AuthorizedFeatureRetrievedEvent>().Publish(GroupItems); }
public UserViewModel(ILoginModel loginBack, IRoomModel roomBack) { _roomBack = roomBack; _loginBack = loginBack; LogoutButton_Clicked = new DelegateCommand(Logout, () => LogoutStatus == "Logout"); Message_Sent = new DelegateCommand(SendNewMessage, () => !string.IsNullOrWhiteSpace(SendMessageText) && LogoutStatus == "Logout"); NewLine_Added = new DelegateCommand(() => { SendMessageText += "\r\n"; }); Invites = new ObservableCollection <InviteViewModel>(); NewJoin_Clicked = new DelegateCommand(JoinNewRoom, () => !string.IsNullOrEmpty(RoomToJoin)); _roomBack.RoomSyncCompleted += OnRoomReady; _roomBack.NewInvite += OnNewInvite; _roomBack.RoomJoined += OnRoomJoined; _loginBack.LogoutCompleted += OnLogoutAttempted; }
public void SetUp() { //Setup mocks _userCollector = Substitute.For <IUserCollector>(); _userCollector.GetShoppinglistId("").ReturnsForAnyArgs(5); _itemCollector = Substitute.For <IItemCollector>(); //Setup reals _scheduler = new TimerScheduler(2); _loginModel = new LoginModel(_userCollector); _shoppingListModel = new ScheduledShoppingListModel(_itemCollector, _scheduler, _loginModel); _sut = new ShoppingListViewModel(_shoppingListModel); //Login with Henrik _userCollector.DoesUserExist("", "").ReturnsForAnyArgs(true); _loginModel.Login("Henrik", "secret"); }
public void SetUp() { //Setup mocks _userCollector = Substitute.For<IUserCollector>(); _userCollector.GetShoppinglistId("").ReturnsForAnyArgs(5); _itemCollector = Substitute.For<IItemCollector>(); //Setup reals _scheduler = new TimerScheduler(2); _loginModel = new LoginModel(_userCollector); _shoppingListModel = new ScheduledShoppingListModel(_itemCollector, _scheduler, _loginModel); _sut = new ShoppingListViewModel(_shoppingListModel); //Login with Henrik _userCollector.DoesUserExist("", "").ReturnsForAnyArgs(true); _loginModel.Login("Henrik", "secret"); }
public bool IsAdmin(ILoginModel loginModel) { return((RoleType)_context.ExecuteScalar <int>(@" SELECT CustomerRoleId FROM Customers WHERE Email = @email AND CustomerPassword = @password ", new { email = loginModel.Login, password = ToMd5(loginModel.Password) }) == RoleType.Admin); }
/// <summary> /// Sets upp all the ViewModels and Models /// </summary> public ViewModelLocator() { _messageBoxService = new MessageBoxService(); _loginModel = new LoginModel(new UserHttpCollector(5)); _foodplanCollector = new FoodplanHttpCollector(); _loginViewModel = new LoginViewModel(_loginModel, _messageBoxService, new WindowOpeningService()); _recipeListModel = new RecipeListModel(new RecipeHTTPCollector()); _shoppingListModel = new ScheduledShoppingListModel (new ItemHttpCollector(), new TimerScheduler(60), _loginModel); _shoppingListViewModel = new ShoppingListViewModel(_shoppingListModel); _foodplanModel = new FoodplanModel (_foodplanCollector, _shoppingListModel, _recipeListModel, _loginModel, _messageBoxService); _recipeViewModel = new RecipeListViewModel(_recipeListModel, 300, _foodplanModel, _messageBoxService); _addRecipeWindowViewModel = new AddRecipeWindowViewModel(_recipeListModel, new DialogImageChooser()); _foodplanViewModel = new FoodplanViewModel(_foodplanModel); _mwmvvm = new MainWindowViewModel(); }
public async Task <IActionResult> Auth(LoginDTO model) { ILoginModel loginModel = ModelManager.Login; Mapper.Map <LoginDTO, ILoginModel>(model, loginModel); bool isAuthenticated = await ServiceManager.LoginService.CheckLogin(loginModel); string token = string.Empty; if (isAuthenticated) { token = JwtTokenhelper.Token(AppSettings.Secret, loginModel); } return(Ok(new { token })); }
public static string Token(string secret, ILoginModel loginModel) { var tokenHandler = new JwtSecurityTokenHandler(); var key = Encoding.ASCII.GetBytes(secret); var tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, loginModel.Username.ToString()), new Claim(ClaimTypes.UserData, loginModel.UserId.ToString()) }), Expires = DateTime.UtcNow.AddDays(1), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature) }; var token = tokenHandler.CreateToken(tokenDescriptor); return(tokenHandler.WriteToken(token)); }
/// <summary> /// Sets up the ScheduledShoppingListModel with constructorinjection /// </summary> /// <param name="itemCollector"></param> /// <param name="scheduler"></param> /// <param name="loginModel"></param> public ScheduledShoppingListModel(IItemCollector itemCollector, IScheduler scheduler, ILoginModel loginModel) { if (itemCollector == null) { throw new ArgumentNullException(); } if (scheduler == null) { throw new ArgumentNullException(); } _shoppingList = new List <Item>(); _itemCollector = itemCollector; _scheduler = scheduler; _loginModel = loginModel; UpdateShoppingList(); _scheduler.Tick += UpdateShoppingList; _scheduler.Start(); }
public IAuthResult Login(ILoginModel model) { var result = new AuthResult { Message = Constants.MessageLoginFailUnknow, Success = false }; UserService = Container.Resolve <IUserService>(); var user = UserService.GetByLoginPassword(model.Login.ToLower(), model.Password); if (user != null) { result.Success = true; result.Message = Constants.MessageLoginSuccess; result.Login = user.Login; result.UserID = user.Id.ToString(); } return(result); }
public void Setup() { //Setup mocks _foodplanCollector = Substitute.For <IFoodplanCollector>(); _itemCollector = Substitute.For <IItemCollector>(); _userCollector = Substitute.For <IUserCollector>(); _recipeCollector = Substitute.For <IRecipeCollector>(); //Setup reals _loginModel = new LoginModel(_userCollector); _shoppingListModel = new ScheduledShoppingListModel (_itemCollector, new TimerScheduler(60), _loginModel); _recipeListModel = new RecipeListModel(_recipeCollector); // Uut _uut = new FoodplanModel(_foodplanCollector, _shoppingListModel, _recipeListModel, _loginModel); _uut.Foodplan = new Foodplan() { RecipeList = new List <Tuple <Recipe, DateTime> >() }; }
/// <summary> /// Sets up the LoginViewModel using constructor injection /// </summary> /// <param name="model"></param> /// <param name="messageService"></param> /// <param name="wos"></param> public LoginViewModel(ILoginModel model, IMessageBoxService messageService, IWindowOpeningService wos) { if (model == null) { throw new ArgumentNullException(); } if (messageService == null) { throw new ArgumentNullException(); } if (wos == null) { throw new ArgumentNullException(); } _model = model; _messageService = messageService; _wos = wos; UserName = ""; Password = ""; }
public void SetUp() { _recipeSizeWidth = 220; //Setup mocks _foodplanCollector = Substitute.For<IFoodplanCollector>(); _recipeCollector = Substitute.For<IRecipeCollector>(); _msgService = Substitute.For<IMessageBoxService>(); _itemCollector = Substitute.For<IItemCollector>(); _userCollector = Substitute.For<IUserCollector>(); _shoppingListModel = Substitute.For<IShoppingListModel>(); //Setup reals _loginModel = new LoginModel(_userCollector); _recipeListModel = new RecipeListModel(_recipeCollector); _foodplanModel = new FoodplanModel(_foodplanCollector, _shoppingListModel, _recipeListModel, _loginModel, _msgService); _foodplanModel.Foodplan.RecipeList = new List<Tuple<Recipe, DateTime>>(); _sut = new RecipeListViewModel(_recipeListModel, _recipeSizeWidth, _foodplanModel, _msgService); //Login with Henrik _userCollector.DoesUserExist("", "").ReturnsForAnyArgs(true); _loginModel.Login("Henrik", "secret"); }
public async Task <LoginResult> LogIn(ILoginModel model) { var user = _unitOfWork.UserQueries.GetByEmailWithPermissions(model.Email); var loginResult = _userService.Login(user, model.Password, LoginTypes.Default.ToInt()); if (!loginResult.Successful) { return(loginResult); } // Identify login by session guid rather than email, because session guid tells us everything (email, tenant, session) and can't be fabricated var permissions = string.Join(',', user.Permissions.Select(x => x.PermissionTypeId)); var claims = new List <Claim> { new Claim(ClaimTypes.NameIdentifier, loginResult.SessionGuid), new Claim(ClaimTypes.Email, user.Email), new Claim(ClaimTypes.Name, user.Email), new Claim(CustomClaimTypes.UserId, user.Id.ToString()), new Claim(CustomClaimTypes.TenantId, user.TenantId.ToString()), new Claim(CustomClaimTypes.Permissions, permissions), }; // authentication successful so generate jwt token var key = Encoding.ASCII.GetBytes(_appSettings.JwtSecret); var tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(claims, JwtBearerDefaults.AuthenticationScheme), Expires = DateTime.UtcNow.AddDays(1), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature) }; var tokenHandler = new JwtSecurityTokenHandler(); var token = tokenHandler.CreateToken(tokenDescriptor); loginResult.Token = tokenHandler.WriteToken(token); //await _httpContextAccessor.HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity)); return(loginResult); }
public async Task <IActionResult> Authunticate(UserDTO model) { IUserModel userModel = ModelManager.User; var config = new MapperConfiguration(cfg => cfg.CreateMap <UserDTO, IUserModel>()); Mapper.Map <UserDTO, IUserModel>(model, userModel); ILoginModel loginModel = ModelManager.Login; loginModel.Username = userModel.Email; loginModel.UserId = userModel.UserId; string token = string.Empty; if (loginModel != null) { token = JwtTokenhelper.Token(AppSettings.Secret, loginModel); } return(Ok(new { token })); }
public void SetUp() { _recipeSizeWidth = 220; //Setup mocks _foodplanCollector = Substitute.For <IFoodplanCollector>(); _recipeCollector = Substitute.For <IRecipeCollector>(); _msgService = Substitute.For <IMessageBoxService>(); _itemCollector = Substitute.For <IItemCollector>(); _userCollector = Substitute.For <IUserCollector>(); _shoppingListModel = Substitute.For <IShoppingListModel>(); //Setup reals _loginModel = new LoginModel(_userCollector); _recipeListModel = new RecipeListModel(_recipeCollector); _foodplanModel = new FoodplanModel(_foodplanCollector, _shoppingListModel, _recipeListModel, _loginModel, _msgService); _foodplanModel.Foodplan.RecipeList = new List <Tuple <Recipe, DateTime> >(); _sut = new RecipeListViewModel(_recipeListModel, _recipeSizeWidth, _foodplanModel, _msgService); //Login with Henrik _userCollector.DoesUserExist("", "").ReturnsForAnyArgs(true); _loginModel.Login("Henrik", "secret"); }
public void SetUp() { //Setup mocks _foodplanCollector = Substitute.For<IFoodplanCollector>(); _recipeCollector = Substitute.For<IRecipeCollector>(); _msgService = Substitute.For<IMessageBoxService>(); _itemCollector = Substitute.For<IItemCollector>(); _userCollector = Substitute.For<IUserCollector>(); //Setup reals _scheduler = new TimerScheduler(2); _loginModel = new LoginModel(_userCollector); _recipeListModel = new RecipeListModel(_recipeCollector); _shoppingListModel = new ScheduledShoppingListModel(_itemCollector, _scheduler, _loginModel); _foodplanModel = new FoodplanModel (_foodplanCollector, _shoppingListModel, _recipeListModel, _loginModel, _msgService); _sut = new FoodplanViewModel(_foodplanModel) { Foodplan = new ObservableCollection<Recipe>() }; _foodplanModel.Foodplan.RecipeList = new List<Tuple<Recipe, DateTime>>(); //Login with Henrik _userCollector.DoesUserExist("", "").ReturnsForAnyArgs(true); _loginModel.Login("Henrik", "secret"); }
public LoginController() { loginModel = new LoginModel(); }
public LoginController() { _context = new LoginModel(); }
public void SetUp() { _collector = Substitute.For <IUserCollector>(); _uut = new LoginModel(_collector); }
public void InitializeLogin(ILoginModel hostform) { this._host = hostform; }
public void setup() { sut = new LoginModel(); }
public void Constructor_CollectorNull_ThrowsNewArgumentNullException() { Assert.Throws <ArgumentNullException>(() => _uut = new LoginModel(null)); }
private void OnAuthenticated(ILoginModel loginModel) { Token = loginModel == null ? null: loginModel.Token; }
public void Constructor_CollectorNull_ThrowsNewArgumentNullException() { Assert.Throws<ArgumentNullException>(() => _uut = new LoginModel(null)); }
public LoginOperation(ILoginModel i_AuthModel) { r_AuthModel = i_AuthModel; ChainedRollback = false; }
public LoginViewModel(ILoginModel i_Model, IExrinContainer i_ExrinContainer) : base(i_ExrinContainer, new LoginVisualState(i_Model)) { r_Model = i_Model; }
public LoginPresenter(ILoginView loginView, ILoginModel loginModel) { _loginView = loginView; _loginModel = loginModel; }
public ActionResult Login(ILoginModel model, string returnUrl) { if (ModelState.IsValid) { if (Membership.ValidateUser(model.UserName, model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl)) { return Redirect(returnUrl); } else { return RedirectToAction("Index", "Home"); } } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } // If we got this far, something failed, redisplay form return View(model); }
public void SetUp() { _collector = Substitute.For<IUserCollector>(); _uut = new LoginModel(_collector); }