示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Username,Password,Email,CreatedDate,UpdatedDate,CreatedBy,UpdatedBy,IsActive,Version,SiteAdmin")] bm_user bm_user)
        {
            if (id != bm_user.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bm_user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!bm_userExists(bm_user.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(bm_user));
        }
示例#2
0
        public async Task <IActionResult> Login([Bind("Username,Password")] bm_user bm_user)
        {
            string username = "";

            if (bm_user.Username != null)
            {
                username = bm_user.Username.Trim();
            }
            string password = "";

            if (bm_user.Password != null)
            {
                password = bm_user.Password.Trim();
            }
            var    Identity       = _configuration.GetConnectionString("Identity");
            var    plainTextBytes = System.Text.Encoding.UTF8.GetBytes(password);
            string passwordBase64 = Identity.ToString() + Convert.ToBase64String(plainTextBytes);
            bool   authenticate   = bm_userExists(username, passwordBase64);

            if (authenticate)
            {
                HttpContext.Session.SetString("LogOnUser", username);
                bool SiteAdmin = _context.bm_user.FirstOrDefault(e => e.Username == username && e.Password == passwordBase64 && e.IsActive == true).SiteAdmin;
                HttpContext.Session.SetString("SiteAdmin", SiteAdmin.ToString());
                return(RedirectToAction("Index", "Gallery"));
            }
            else
            {
                return(RedirectToAction("Login", "Home", new { e = "invalid" }));
            }
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("Id,Username,Password,Email,CreatedDate,UpdatedDate,CreatedBy,UpdatedBy,IsActive,Version,SiteAdmin")] bm_user bm_user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bm_user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(bm_user));
        }