public void TestGetUserSessionBad() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); IUserSessionRepository userSessionRepo = new UserSessionRepository(context); userSessionRepo.Get(userSession.Id); }
public SidebarViewComponent(UserManager <ApplicationUser> userManager, CompanyRepository companyRepository, UserSessionRepository userSessionRepository) { _userManager = userManager; _companyRepository = companyRepository; _userSessionRepository = userSessionRepository; }
public UnitOfWork(AppDbContext context) { this.context = context; Auth = new AuthRepository(this.context); Users = new AccountRepository(this.context); UserSessions = new UserSessionRepository(this.context); Settings = new SettingsRepository(this.context); Clients = new ClientRepository(this.context); PersistedGrants = new PersistentGrantRepository(this.context); SekaniLevels = new SekaniLevelRepository(this.context); SekaniWords = new SekaniWordRepository(this.context); SekaniCategories = new SekaniCategoryRepository(this.context); Topics = new TopicRepository(this.context); EnglishWords = new EnglishWordRepository(this.context); SekaniWordAudios = new SekaniWordAudioRepository(this.context); SekaniRoots = new SekaniRootRepository(this.context); SekaniRootImages = new SekaniRootImageRepository(this.context); SekaniForms = new SekaniFormRepository(this.context); SekaniWordExamples = new SekaniWordExampleRepository(this.context); SekaniWordExampleAudios = new SekaniWordExampleAudioRepository(this.context); SekaniWordAttributes = new SekaniWordAttributeRepository(this.context); SekaniRootsEnglishWords = new SekaniRootEnglishWordRepository(this.context); SekaniRootsTopics = new SekaniRootTopicRepository(this.context); UserActivityStats = new UserActivityStatRepository(this.context); UserLearnedWords = new UserLearnedWordRepository(this.context); UserFailedWords = new UserFailedWordRepository(this.context); GameRepository = new GameRepository(this.context); }
public void TestRemoveUserSessionInvalid() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); IUserSessionRepository userSessionRepo = new UserSessionRepository(context); userSessionRepo.Remove(userSession); }
public CinemaController(UserManager <ApplicationUser> userManager, CinemaRepository cinemaRepository, CompanyRepository companyRepository, UserSessionRepository userSessionRepository) { _userManager = userManager; _cinemaRepository = cinemaRepository; _companyRepository = companyRepository; _userSessionRepository = userSessionRepository; }
public CompanyController(UserManager <ApplicationUser> userManager, CompanyRepository companyRepository, UserSessionRepository userSessionRepository, IOptions <WebApplicationOptions> webApplicationOptions) { _userManager = userManager; _companyRepository = companyRepository; _userSessionRepository = userSessionRepository; _webApplicationOptions = webApplicationOptions.Value; }
public FilmController(FilmRepository filmRepository, UserManager <ApplicationUser> userManager, CompanyRepository companyRepository, UserSessionRepository userSessionRepository, BlobRepository blobRepository) { _filmRepository = filmRepository; _userManager = userManager; _companyRepository = companyRepository; _userSessionRepository = userSessionRepository; _blobRepository = blobRepository; }
public UserSessionDto Login(string userId, string password) { if (string.IsNullOrEmpty(userId)) { throw new ArgumentException("User Id cannot be null", nameof(userId)); } if (string.IsNullOrEmpty(password)) { throw new ArgumentException("Password cannot be null", nameof(password)); } UserLogin userLoginEntity = null; using (UserLoginRepository userLoginRepository = new UserLoginRepository()) { string securePassword = password.Encrypt(); userLoginEntity = userLoginRepository.Find(x => x.UserId == userId && x.Password == securePassword); if (userLoginEntity == null) { throw new ApplicationException("Invalid UserId/Password"); } } using (UserInfoRepository repository = new UserInfoRepository()) { UserInfo userInfo = repository.Find(x => x.UserId == userId); if (userInfo == null) { throw new ApplicationException("User Info not found."); } string sessionId = Guid.NewGuid().ToString(); using (UserSessionRepository userSessionRepository = new UserSessionRepository()) { UserSession userSession = new UserSession { UserId = userId, SessionId = sessionId, ValidFrom = DateTime.Now, ExpiresOn = DateTime.Now.AddDays(1) }; userSessionRepository.Insert(userSession); } return(new UserSessionDto() { SessionId = sessionId, User = new UserInfoDto() { FirstName = userInfo.FirstName, LastName = userInfo.LastName, Email = userInfo.EMail, UserId = userInfo.UserId, Gender = userInfo.Gender } }); } }
public RoleController(RoleManager <IdentityRole> roleMgr, UserManager <ApplicationUser> userMgr, CompanyMemberRepository companyMemberRepository, CompanyRepository companyRepository, UserSessionRepository userSessionRepository) { _roleManager = roleMgr; _userManager = userMgr; _companyMemberRepository = companyMemberRepository; _companyRepository = companyRepository; _userSessionRepository = userSessionRepository; }
public void TestGetUserSessionByToken() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); IUserSessionRepository userSessionRepo = new UserSessionRepository(context); userSessionRepo.Add(userSession); UserSession userSessionResult = userSessionRepo.GetUserSessionByToken(userSession.Token); Assert.AreEqual(user, userSessionResult.User); }
public void TestAddUserSessionOK() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); IUserSessionRepository userSessionRepo = new UserSessionRepository(context); userSessionRepo.Add(userSession); List <UserSession> listOfUserSessions = userSessionRepo.GetAll().ToList(); Assert.AreEqual(userSession, listOfUserSessions[0]); }
public void TestGetUserSessionOK() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); IUserSessionRepository userSessionRepo = new UserSessionRepository(context); userSessionRepo.Add(userSession); UserSession userSessionOfDb = userSessionRepo.Get(userSession.Id); Assert.AreEqual(userSession, userSessionOfDb); }
public UnitOfWork(AppDbContext context) { this._context = context; // repos instantations here... Clients = new ClientRepository(this._context); Users = new UserRepository(this._context); UserSessions = new UserSessionRepository(this._context); PersistedGrants = new PersistedGrantRepository(this._context); }
public PersonalAreaController(UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, CompanyRepository companyRepository, CompanyMemberRepository companyMemberRepository, UserSessionRepository userSessionRepository, ILoggerFactory loggerFactory) { _companyRepository = companyRepository; _userManager = userManager; _companyMemberRepository = companyMemberRepository; _userSessionRepository = userSessionRepository; _signInManager = signInManager; _logger = loggerFactory.CreateLogger <PersonalAreaController>(); }
public FilmSessionController(UserManager <ApplicationUser> userManager, FilmRepository filmRepository, HallRepository hallRepository, CinemaRepository cinemaRepository, CompanyRepository companyRepository, UserSessionRepository userSessionRepository, FilmSessionRepository filmSessionRepository) { _userManager = userManager; _filmRepository = filmRepository; _hallRepository = hallRepository; _cinemaRepository = cinemaRepository; _companyRepository = companyRepository; _userSessionRepository = userSessionRepository; _filmSessionRepository = filmSessionRepository; }
public SuperAdminController(UserManager <ApplicationUser> userMgr, IUserValidator <ApplicationUser> userValid, IPasswordValidator <ApplicationUser> passValid, IPasswordHasher <ApplicationUser> passHasher, CompanyMemberRepository companyMemberRepository, CompanyRepository companyRepository, UserSessionRepository userSessionRepository) { _userManager = userMgr; _userValidator = userValid; _passwordValidator = passValid; _passwordHasher = passHasher; _companyMemberRepository = companyMemberRepository; _companyRepository = companyRepository; _userSessionRepository = userSessionRepository; }
public AuthorisationMiddleware(EmployeeSessionRepository employeeSessions, UserSessionRepository userSessions, EmployeeRoleRepository employeeRoles, TokenRepository tokenRepository, IDistributedCache cache, ISettings settings) { this.employeeSessions = employeeSessions; this.userSessions = userSessions; this.employeeRoles = employeeRoles; this._tokenRepository = tokenRepository; this.settings = settings; this.cache = cache; }
public AuthoriseController(EmployeeRepository employees, EmployeeSessionRepository employeeSessions, UserRepository users, UserSessionRepository userSessions, TokenUtil tokenUtil, ISettings settings, IBillingManager billingManager, ICryptoHelper crypto) { this.employees = employees; this.employeeSessions = employeeSessions; this.users = users; this.userSessions = userSessions; this.tokenUtil = tokenUtil; this.settings = settings; this.billingManager = billingManager; this.crypto = crypto; }
public static UserProfileSessionData Get() { //From Session if (HttpContext.Current.Session[userProfile] != null) { return(HttpContext.Current.Session[userProfile] as UserProfileSessionData); } var userID = CookieStorage.Get(userCookieName); Guid id; //From Cookies if (string.IsNullOrEmpty(userID) == false && Guid.TryParse(userID, out id) == true) { UserRepository userRepository = new UserRepository(new plat2platContext()); var user = userRepository.GetUserByID(id); if (user != null) { UserProfileSessionData userProfile = new UserProfileSessionData(user); UserStorage.Set(userProfile); Log.Information("Get user from cookie"); return(userProfile); } } //From DB UserSessionRepository us = new UserSessionRepository(new plat2platContext()); UserSession userSession = us.GetUserSessionBySessionID(HttpContext.Current.Session.SessionID, DateTime.Now.AddDays(-5)); if (userSession != null) { Log.Information("Get user from DB"); return(UserStorage.Set(userSession.User)); } //if (HttpContext.Current.User.Identity != null // && string.IsNullOrEmpty(HttpContext.Current.User.Identity.Name) != null) //{ //} //if (FormsAuthentication.GetAuthCookie() //{ //} return(null); }
public void TestGetAllUsersSessionsOK() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); IUserSessionRepository userSessionRepo = new UserSessionRepository(context); userSessionRepo.Add(userSession); userSessionRepo.Add(userSession2); List <UserSession> listTest = new List <UserSession>(); listTest.Add(userSession); listTest.Add(userSession2); List <UserSession> listOfUserSessions = userSessionRepo.GetAll().ToList(); CollectionAssert.AreEqual(listTest, listOfUserSessions); }
public bool Logout(string sessionId) { int rowsDeleted = 0; using (UserSessionRepository userSessionRepository = new UserSessionRepository()) { UserSession session = userSessionRepository.Find(x => x.SessionId == sessionId); if (session != null) { rowsDeleted = userSessionRepository.Delete(session); } else { _loggger.Error(string.Format("Session with session id {0} not found", sessionId)); throw new ApplicationException("Session not found."); } } return(rowsDeleted > 0); }
public UserSessionDto GetUserSessionBySessionId(string sessionId) { if (string.IsNullOrEmpty(sessionId)) { return(null); } UserSession userSession = null; using (UserSessionRepository userSessionRepository = new UserSessionRepository()) { userSession = userSessionRepository.Find(x => x.SessionId == sessionId); } if (userSession == null) { return(null); } else { UserInfo userInfo = new UserInfo(); using (UserInfoRepository userInfoRepository = new UserInfoRepository()) { userInfo = userInfoRepository.Find(x => x.UserId == userSession.UserId); } if (userInfo != null) { return(new UserSessionDto() { SessionId = sessionId, User = new UserInfoDto() { FirstName = userInfo.FirstName, LastName = userInfo.LastName, Email = userInfo.EMail, UserId = userInfo.UserId, Gender = userInfo.Gender } }); } } return(null); }
private static SuccessFailCode WriteSessions(Options opts) { var client = new DocumentClient(new Uri(opts.Cosmos.Endpoint), opts.Cosmos.Key); var title = opts.QuestionVersionKey.Split('-').Last(); var questionSetRepository = new QuestionSetRepository(client, new OptionsWrapper <CosmosSettings>(opts.Cosmos)); var sessionRepository = new UserSessionRepository(client, new OptionsWrapper <CosmosSettings>(opts.Cosmos)); var questionSet = questionSetRepository.GetLatestQuestionSetByTypeAndKey("short", title) .GetAwaiter().GetResult(); using (var fs = File.OpenWrite(opts.FileName + ".csv")) using (var sw = new StreamWriter(fs)) using (var csv = new CsvWriter(sw)) { csv.WriteHeader <UserSessionEnty>(); csv.NextRecord(); for (var i = 0; i < opts.NumberOfSessions; i++) { var session = CreateSession(questionSet.QuestionSetVersion, questionSet.MaxQuestions); Console.WriteLine($"Creating User Session: {i} {session.UserSessionId}"); sessionRepository.CreateUserSession(session).GetAwaiter().GetResult(); csv.WriteRecord(new UserSessionEnty { SessionId = session.UserSessionId, UserName = "" }); csv.NextRecord(); } } return(SuccessFailCode.Succeed); }
public WalletService(UserSessionRepository userSessionRepository, WalletDAO walletDao) { this.userSessionRepository = userSessionRepository; this.walletDao = walletDao; }
public IActionResult GetPost() { var post = new UserSessionRepository().ListUserSession(); return(Ok(post)); }
public LoginUserHandler(string connectionString) : base(connectionString) { _usersRepository = new UsersRepository(connectionString); _userSessionRepository = new UserSessionRepository(connectionString); }
public AuthorizationController(IRepositoryData <UserData> userSessionRepo) { _userSessionRepository = new UserSessionRepository(userSessionRepo); }
public LogoutUserHandler(string connectionString) : base(connectionString) { UserSessionRepository = new UserSessionRepository(connectionString); }
public GetItemHandler(string connectionString) : base(connectionString) { _itemRepository = new ItemsRepository(connectionString); _userSessionRepository = new UserSessionRepository(connectionString); }
static CookieAuthenticationModule() { database = new PostgreSqlDatabase("Host=localhost;Port=5433;Username=postgres;Password=Badger123!;Database=MonsterTradingCardGame"); userSessionRepository = new UserSessionRepository(database); }