public bool CheckAuthenticationLoginSMS([FromBody] ACCOUNTModel account) { USERModel user = new USERRepository().GetUSERByIdAccount(account); //Xác thực bằng số điện thoại return(AUTHENTICATIONRepository.VerifySMSCode(user.sdt, "84", account.ma_code_xac_thuc));; }
public bool SendAuthenticationSMS([FromBody] ACCOUNTModel account) { USERModel user = new USERRepository().GetUSERByIdAccount(account); //Xác thực bằng số điện thoại return(AUTHENTICATIONRepository.SendVerifySMS(user.sdt, "84")); }
public USERModel SaveLoginInfo(int id_account) { ACCOUNTModel account = new ACCOUNTModel(); account.id = id_account; USERModel user = new USERRepository().GetUSERByIdAccount(account); //rememberMe: tự nhớ ho_ten_nguoi_dung của lần trước để tự động đăng nhập hay không? bool rememberMe = false; var authTicket = new FormsAuthenticationTicket( 1, // version $"{user.ma_nguoi_dung}_{user.ho_ten_nguoi_dung}", // user name DateTime.Now, // created DateTime.Now.AddMinutes(480), // expires rememberMe, // persistent? user.ma_role, // can be used to store roles "/" ); string encryptedTicket = FormsAuthentication.Encrypt(authTicket); var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); Response.Cookies.Add(authCookie); return(user); }
public bool CheckAuthenticationLoginGG([FromBody] ACCOUNTModel account) { USERModel user = new USERRepository().GetUSERByIdAccount(account); TwoFactorAuthenticator TwoFacAuth = new TwoFactorAuthenticator(); string UserUniqueKey = (user.ma_nguoi_dung + user.ho_ten_nguoi_dung); bool isValid = TwoFacAuth.ValidateTwoFactorPIN(UserUniqueKey, account.ma_code_xac_thuc); return(isValid); }
public string SendAuthenticationGG([FromBody] ACCOUNTModel account) { USERModel user = new USERRepository().GetUSERByIdAccount(account); //Two Factor Authentication Setup TwoFactorAuthenticator TwoFacAuth = new TwoFactorAuthenticator(); string UserUniqueKey = (user.ma_nguoi_dung + user.ho_ten_nguoi_dung); var setupInfo = TwoFacAuth.GenerateSetupCode("IOT Manager System", user.ma_nguoi_dung, UserUniqueKey, 200, 200); return(setupInfo.QrCodeSetupImageUrl); }
// GET: PageUser public ActionResult Index() { var temp = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name; ViewBag.MaUser = loginedUser.ma_nguoi_dung; ViewBag.NameUser = loginedUser.ho_ten_nguoi_dung; USERModel user = new USERRepository().GetByMaUser(temp.Split('_')[0]); DateTime dt = DateTime.ParseExact(user.ngay_sinh, "MM/dd/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture); user.ngay_sinh = dt.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture); ViewBag.InfoUser = user; ViewBag.InfoAccount = new ACCOUNTRepository().GetByMaUser(temp.Split('_')[0]); return(View("PageUser")); }
public bool SendAuthenticationGmail([FromBody] ACCOUNTModel account) { try { MailMessage mail = new MailMessage(); SmtpClient smtpC = new SmtpClient("smtp.gmail.com"); //From address to send email mail.From = new MailAddress("*****@*****.**"); //To address to send email USERModel user = new USERRepository().GetUSERByIdAccount(account); mail.To.Add(user.email); string thoi_gian_login_gmail = DateTime.Now.ToString("ddMMyyyyHHmmss"); var hash = $"{account.id}_{thoi_gian_login_gmail}"; hash = System.Web.HttpUtility.UrlEncode(EncryptTo.Encrypt(hash)); string href = "http://*****:*****@gmail.com", "0070091994"); smtpC.EnableSsl = true; smtpC.Send(mail); //Lưu vào DB new ACCOUNTRepository().UpdateThoiGianLoginGmail(account.id, thoi_gian_login_gmail); return(true); } catch (Exception) { return(false); } }
public ActionResult Read([DataSourceRequest] DataSourceRequest request) { IEnumerable <USERModel> list = new USERRepository().GetAll(); return(Json(list.ToDataSourceResult(request))); }