public async Task <ActionResult> Create(RSUser user, string newpassword, string confirmpassword) { if (ModelState.IsValid) { db.Users.Add(user); if (newpassword == confirmpassword) { user.DependencyInjection(); user.CreatePassword(newpassword); } else { ViewBag.ShowMessage = true; ViewBag.MessageColor = "red"; ViewBag.Message = Resources.Resources.PasswordsDontMatch; return(View(user)); } await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(user)); }
public async Task <ActionResult> DeleteConfirmed(int id) { RSUser user = await db.Users.FindAsync(id); db.Users.Remove(user); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <IActionResult> UnpinApplication(long loanApplicationId, [FromQuery] string session = "") { RSUser user = ((RSUser)this.RouteData.Values[nameof(RSUser)]); UserLoanApplication userLoanApplication = await userLoanApplicationService.UnpinApplication(user.UserName, loanApplicationId); return(Ok(userLoanApplication)); }
public async Task <IActionResult> CreateBulk([FromBody] SavingsDailyBalanceBulkRequest request, [FromQuery] string session = "") { RSUser user = (RSUser)this.RouteData.Values[nameof(RSUser)]; request.Data.ForEach(e => e.CreatedBy = user.UserName); var result = await service.CreateBulk(request); return(Created("", result)); }
public async Task <IActionResult> GetUserDetails([FromQuery] string session) { RSUser user = await userRepository.GetUserDetailsBySession(session); if (user is null) { return(NotFound()); } return(Ok(new SingleDataResponse <RSUser> { Data = user })); }
public async Task <IActionResult> PaginateUserApplications([FromQuery] PageOption pageOption, string session = "") { RSUser user = ((RSUser)this.RouteData.Values[nameof(RSUser)]); IPagedList <LoanApplicationResponseDTO> data = await this.loanApplicationService.PageUserApplications(pageOption, user.UserName); PagedListMetaData metaData = data.GetMetaData(); PagedDataResponse pagedData = new PagedDataResponse { Data = data, MetaData = metaData }; return(Ok(pagedData)); }
public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RSUser user = await db.Users.FindAsync(id); if (user == null) { return(HttpNotFound()); } return(View(user)); }
public async Task <ActionResult> Edit(RSUser user, string newpassword, string confirmpassword) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; if (!string.IsNullOrWhiteSpace(newpassword) & newpassword == confirmpassword) { user.DependencyInjection(); user.CreatePassword(newpassword); } await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(user)); }
protected override void Seed(RSDbContext context) { try { if (!context.Users.Any()) { RSUser user0 = new RSUser() { Id = 0, Name = "Admin", Username = "******", IsAdmin = true, IsWaiter = true }; user0.DependencyInjection(); user0.CreatePassword("admin"); context.Users.AddOrUpdate(user0); } if (!context.Styles.Any(s => s.Type == (int)RSStyleType.MenuStyle)) { context.Styles.Add(new Models.RSStyle() { Path = "/Content/Menu/default.css", Selected = true, Title = "Default Menu Style", Type = (int)RSStyleType.MenuStyle, Notes = "This theme was provided by with the product to showcase menu printing capabilities of the product.", }); context.Styles.Add(new Models.RSStyle() { Path = "/Content/Receipt/default.css", Selected = true, Title = "Default Receipt Style", Type = (int)RSStyleType.MenuStyle, Notes = "This theme was provided by with the product to showcase receipt printing capabilities of the product.", }); } } catch (Exception ex) { } }
private async Task CheckIfAuthenticated(AuthorizationFilterContext context, IRSUserRepository userRepository, string session) { RSUser user = await userRepository.GetUserAsync(session); if (user is null) { UnAuthorized unAuthorized = new UnAuthorized(); unAuthorized.Message = "Unauthenticated"; context.Result = new JsonResult(unAuthorized) { StatusCode = unAuthorized.Status }; } context.RouteData.Values.Add(nameof(RSUser), user); }
public bool LogIn(string username, string password) { using (RSDbContext Db = new RSDbContext()) { RSUser user = Db.Users.FirstOrDefault(u => u.Username == username); user.DependencyInjection(); if (user == null) return false; if (!user.CheckPassword(password)) return false; HttpContext.Current.Response.Cookies[COOKIE_NAME][COOKIE_USERNAME] = user.Username; HttpContext.Current.Response.Cookies[COOKIE_NAME][COOKIE_PASSWORDHASH] = BitConverter.ToString(user.PasswordHash); HttpContext.Current.Response.Cookies[COOKIE_NAME].Expires = DateTime.Now.AddDays(30); CurrentUser = user; return true; } }
public System.Security.Principal.IIdentity CreateIdentity() { if (HttpContext.Current.Request.Cookies[COOKIE_NAME] == null) return null; string username = HttpContext.Current.Request.Cookies[COOKIE_NAME][COOKIE_USERNAME]; string password = HttpContext.Current.Request.Cookies[COOKIE_NAME][COOKIE_PASSWORDHASH]; if (CurrentUser == null) { IEnumerable<RSUser> allUsers; do { allUsers = Db.Users.ToList(); } while (!allUsers.Any()); CurrentUser = allUsers.SingleOrDefault(u => u.Name == username && BitConverter.ToString(u.PasswordHash) == password); } return CurrentUser; }
private async Task CheckPermission(AuthorizationFilterContext context, IRSUserRepository userRepository, string session) { bool hasPermission = await userRepository.HasPermisson(session, permission); if (!hasPermission) { int statusCode = (int)HttpStatusCode.Forbidden; context.Result = new JsonResult(new UnAuthorized { Message = $"This action requires permission {permission}.", Status = statusCode }) { StatusCode = statusCode }; } RSUser user = await userRepository.GetUserAsync(session); context.RouteData.Values.Add(nameof(RSUser), user); }
public System.Security.Principal.IIdentity CreateIdentity() { if (HttpContext.Current.Request.Cookies[COOKIE_NAME] == null) { return(null); } string username = HttpContext.Current.Request.Cookies[COOKIE_NAME][COOKIE_USERNAME]; string password = HttpContext.Current.Request.Cookies[COOKIE_NAME][COOKIE_PASSWORDHASH]; if (CurrentUser == null) { IEnumerable <RSUser> allUsers; do { allUsers = Db.Users.ToList(); } while (!allUsers.Any()); CurrentUser = allUsers.SingleOrDefault(u => u.Name == username && BitConverter.ToString(u.PasswordHash) == password); } return(CurrentUser); }
public bool LogIn(string username, string password) { using (RSDbContext Db = new RSDbContext()) { RSUser user = Db.Users.FirstOrDefault(u => u.Username == username); user.DependencyInjection(); if (user == null) { return(false); } if (!user.CheckPassword(password)) { return(false); } HttpContext.Current.Response.Cookies[COOKIE_NAME][COOKIE_USERNAME] = user.Username; HttpContext.Current.Response.Cookies[COOKIE_NAME][COOKIE_PASSWORDHASH] = BitConverter.ToString(user.PasswordHash); HttpContext.Current.Response.Cookies[COOKIE_NAME].Expires = DateTime.Now.AddDays(30); CurrentUser = user; return(true); } }
public void LogOut() { CurrentUser = null; HttpContext.Current.Response.Cookies[COOKIE_NAME].Expires = DateTime.MinValue; }
private async void App_UserAuthenticated(object sender, RSUser e) { await Globals.myXamApp.SwitchAccount((clsXamPolice)Globals.myXamApp.Controller.Police); }