public IActionResult Login([FromBody] aa0001 aa0001) { if (isExists(aa0001.aa0001c11)) { return(BadRequest("Username is not exist!")); } if (isActive(aa0001.aa0001c11)) { return(BadRequest("Username is not active!")); } aa0001.aa0001c21 = getSalt(aa0001.aa0001c11); string ipAdress = Request.HttpContext.Connection.RemoteIpAddress.ToString(); if (ValidateUser(aa0001)) { var tokenstring = GenerateJWT(); aa0001.aa0001c22 = ipAdress; aa0001.aa0001c24 = tokenstring; aa0001.aa0001c25 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); _context.Update(aa0001); _context.SaveChanges(); return(Ok(new { token = tokenstring })); } else { return(Unauthorized()); } }
public IActionResult Login([FromBody] aa0001 user) { aa0001 checkUser = _db.aa0001 .Where(a => a.aa0001c13 == user.aa0001c13) .Select(a => a).FirstOrDefault(); if (checkUser == null) { return(BadRequest("Mail is not exist!")); } if (checkUser.aa0001c15 == "0") { return(BadRequest("User is not active!")); } user.aa0001c20 = checkUser.aa0001c20; bool result = ValidateUser(user); if (result) { var tokenstring = GenerateJWT(); checkUser.aa0001c24 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); checkUser.aa0001c25 = user.aa0001c25; checkUser.aa0001c26 = tokenstring; _db.Update(checkUser); _db.SaveChanges(); return(Ok(new { token = tokenstring })); } else { return(Unauthorized()); } }
public IActionResult ActiveUser([FromBody] string token) { aa0001 userActive = CheckToken(token); if (userActive != null) { userActive.aa0001c16 = "1"; _context.Update(userActive); _context.SaveChanges(); return(Ok()); } else { return(BadRequest()); } }
public IActionResult ActiveUser([FromQuery] string email) { aa0001 checkUser = _context.aa0001 .Where(a => a.aa0001c14 == email) .Select(a => a).FirstOrDefault(); if (checkUser == null) { ViewData["Message"] = string.Format("Email {0} invaild!", email); return(View()); } checkUser.aa0001c16 = "True"; _context.Update(checkUser); _context.SaveChanges(); ViewData["Message"] = string.Format("Email {0} is actived!", email); return(View()); }
public IActionResult ActiveUser([FromQuery] string email) { aa0001 checkUser = _db.aa0001 .Where(a => a.aa0001c13 == email) .Select(a => a).FirstOrDefault(); if (checkUser == null) { ViewBag.Message = string.Format("Email {0} invaild!", email); return(View()); } checkUser.aa0001c15 = "1"; checkUser.aa0001c23 = "Actived"; _db.Update(checkUser); _db.SaveChangesAsync(); ViewBag.Message = string.Format("Email {0} is actived!", email); return(View()); }
public async Task <IActionResult> Putaa0001(aa0001 aa0001) { //_context.Entry(aa0001).State = EntityState.Modified; try { aa0001 userActive = CheckUser(aa0001.aa0001c11); if (userActive != null) { userActive.aa0001c01 = aa0001.aa0001c01; userActive.aa0001c07 = aa0001.aa0001c07; userActive.aa0001c08 = aa0001.aa0001c08; userActive.aa0001c11 = aa0001.aa0001c11; userActive.aa0001c12 = aa0001.aa0001c12; userActive.aa0001c13 = aa0001.aa0001c13; userActive.aa0001c14 = aa0001.aa0001c14; userActive.aa0001c55 = aa0001.aa0001c55; userActive.aa0001c16 = aa0001.aa0001c16; userActive.aa0001c17 = aa0001.aa0001c17; userActive.aa0001c25 = aa0001.aa0001c25; _context.Update(userActive); await _context.SaveChangesAsync(); return(Ok()); } } catch (DbUpdateConcurrencyException) { if (!aa0001Exists(aa0001.aa0001c01)) { return(NotFound()); } else { throw; } } return(NoContent()); }