public async Task <Result> SendEmailAsync(string email) { var user = await _userQueryRepository.GetUserByEmailAsync(email); if (user == null) { return(Result.Fail <bool>(EC.EmailNotFound, ET.EmailNotFound)); } var securityCode = SecurityCode.Create(ProviderType.Email, email, CodeActionType.ForgotPasswordByEmail); await _securityCodesRepository.CreateAsync(securityCode); var token = _jwtTokenHelper.GenerateTokenWithSecurityCode($"{user.Id}", email, securityCode.Code); var url = $"{_configuration["UiBaseUrl"]}resetpassword?token={token}"; var htmlMessage = $"To reset your password, just click the link below: <a href=\"{HtmlEncoder.Default.Encode(url)}\">clicking here</a>."; try { await _emailSender.SendEmailAsync(email, "Reset your email", htmlMessage); } catch (Exception e) { return(Result.Fail <bool>(EC.EmailFailedSend, ET.EmailFailedSend)); } await _unitOfWorks.CommitAsync(); return(Result.Ok()); }
public IActionResult GetCode() { //待返回对象 var result = new ResponseModel(ResponseCode.Success, "查询成功!"); //调用图片码 string randomCode = SecurityCode.CreateRandomCode(4); if (!string.IsNullOrEmpty(randomCode)) { //字符串加缓存 string keys = "ImageCode_Login" + DateTime.Now.ToString("yyyyMMddHHmmssfffffff");//Guid.NewGuid() TimeSpan ts1 = new TimeSpan(0, 5, 0); CacheManager.Create().Set(keys, randomCode, ts1); //读取图片 byte[] imgCode = SecurityCode.CreateValidateGraphic(randomCode); string base64str = Convert.ToBase64String(imgCode); var ImagCode = new { imgcode = "data:image/png;base64," + base64str, imgkey = keys, }; result.data = ImagCode; } return(Json(result)); }
public override int GetHashCode() { int hashCode = SecurityCode.GetHashCode() ^ StrikePrice.GetHashCode() ^ Expiry.GetHashCode() ^ PremiumMultiplier.GetHashCode(); return(hashCode); }
public static SecurityCode CheckAccess(string connectString, SecurityRequest securityRequest, out string message) { SecurityCode securityCode = CheckAccess(connectString, securityRequest, new System.Diagnostics.StackFrame(1).GetMethod()); message = Enum.GetName(typeof(SecurityCode), securityCode); return(securityCode); }
public async Task <Result> SendSmsCodeAsync(string phoneNumber, string countryCode) { var isExist = await _userQueryRepository.IsExistPhoneAsync(phoneNumber); if (!isExist) { return(Result.Fail(EC.PhoneNotFound, ET.PhoneNotFound)); } var code = SecurityCode.Create(ProviderType.Phone, phoneNumber, CodeActionType.ForgotPasswordByPhone); await _securityCodesRepository.CreateAsync(code); await _unitOfWorks.CommitAsync(); var smsSender = new SmsSender(_globalSettings); var result = await smsSender.SendSmsAsync(phoneNumber, $"{code.Code} is your verification code."); if (result == null) { return(Result.Fail(EC.SmsServiceFailed, ET.SmsServiceFailed)); } return(Result.Ok()); }
public async Task SendSecurityCodeAsync(AppUser user) { string code; SecurityCode securityCode = await FindCodeAsync(user.Id); if (HasValidCode(securityCode)) { await _mailService.SendMail(user.Email, "Article App SecurityCode", securityCode.Code); return; } else { code = GenerateCode(); SecurityCode sCode = new SecurityCode { UserId = user.Id, Code = code, IsValid = true, }; await _dbSet.AddAsync(sCode); _unitOfWork.Save(); await _mailService.SendMail(user.Email, "Article App SecurityCode", code); } }
public async Task <Result <bool> > SendEmailConfirmEmailAsync(int userId) { var user = await _userQueryRepository.GetUserByIdAsync(userId); if (user == null) { return(Result.Fail <bool>(EC.UserNotFound, ET.UserNotFound)); } if (user.EmailConfirmed) { return(Result.Fail <bool>(EC.EmailAlreadyConfirmed, ET.EmailAlreadyConfirmed)); } var securityCode = SecurityCode.Create(ProviderType.Email, user.Email, CodeActionType.ConfirmEmail); await _securityCodesRepository.CreateAsync(securityCode); var token = _jwtTokenHelper.GenerateTokenWithSecurityCode(userId.ToString(), user.Email, securityCode.Code); var url = $"{_configuration["UiBaseUrl"]}confirm-email?token={token}"; var htmlMessage = $"Please confirm your email by <a href=\"{HtmlEncoder.Default.Encode(url)}\">clicking here</a>."; await _emailSender.SendEmailAsync(user.Email, "Confirm email", htmlMessage); await _unitOfWorks.CommitAsync(); return(Result.OK(true)); }
public RegisterForm(LoginForm login) { this.login = login; InitializeComponent(); securitycode = new SecurityCode(4); user = new BLL.User(); }
/// <summary> /// 发送邮件验证码 /// </summary> public ActionResult SendEmail1(string mailTo, string mailSubject, string mailContent) { try { //验证码 SecurityCode scode = new SecurityCode(); string code = scode.CreateRandomCode(5); Session["code"] = code; SmtpClient mailClient = new SmtpClient("smtp.qq.com"); mailClient.EnableSsl = true; mailClient.UseDefaultCredentials = false; //Credentials登陆SMTP服务器的身份验证. mailClient.Credentials = new NetworkCredential("*****@*****.**", "aiookfzkwekjijif"); //邮箱, MailMessage message = new MailMessage(new MailAddress("*****@*****.**"), new MailAddress(mailTo)); //发件人,收件人 message.IsBodyHtml = true; message.Body = mailContent + ":" + code; //邮件内容 message.Subject = mailSubject; //邮件主题 mailClient.Send(message); // 发送邮件 return(Json(new { date = "已发送,请查收", type = 1 }, JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json(new { date = "发送失败:" + e.Data, type = 0 }, JsonRequestBehavior.AllowGet)); } }
public ActionResult GetSecurityCode() { SecurityCode code = new SecurityCode(); Session["skey"] = code.CreateRandomCode(4); byte[] buf = code.CreateValidateGraphic(Session["skey"].ToString()); return(File(buf, "image/Jpeg")); }
public ActionResult DeleteConfirmed(int id) { SecurityCode securityCode = db.SecurityCodes.Find(id); db.SecurityCodes.Remove(securityCode); db.SaveChanges(); return(RedirectToAction("Index")); }
public bool HasValidCode(SecurityCode code) { if (code != null) { return(true); } return(false); }
public void ShouldHaveCorrectCode() { const string code = "123"; var securityCode = SecurityCode.For(code); securityCode.Code.ShouldBe(code); }
public ActionResult insert_tenant(Tenant rs) { using (JobDbContext2 context = new JobDbContext2()) { var conn = context.Database.Connection; var connectionState = conn.State; try { //================== Get Security Code ========================== var SercurityCode = ""; SecurityCode SC = new SecurityCode(); var res = context.SecurityCode.SqlQuery(@"exec uspGenerateSecurityCode"); SC = res.FirstOrDefault(); SercurityCode = SC.Code; //================== Insert Into Teanant ========================== if (connectionState != ConnectionState.Open) { conn.Open(); } using (var cmd = conn.CreateCommand()) { cmd.CommandText = "uspInsertTenant"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@pName", rs.Name)); cmd.Parameters.Add(new SqlParameter("@pDbname", rs.DbName)); cmd.Parameters.Add(new SqlParameter("@pAddress", rs.Address)); cmd.Parameters.Add(new SqlParameter("@pMobile", rs.Mobile)); cmd.Parameters.Add(new SqlParameter("@pContactPerson", rs.ContactPerson)); cmd.Parameters.Add(new SqlParameter("@pSecurityCode", SercurityCode)); cmd.Parameters.Add(new SqlParameter("@pisActive", true)); cmd.Parameters.Add(new SqlParameter("@pisReadOnly", false)); cmd.Parameters.Add(new SqlParameter("@pRegID", Convert.ToInt64(Session["RegID"].ToString()))); cmd.Parameters.Add(new SqlParameter("@pPlanId", rs.PlanID)); cmd.Parameters.Add(new SqlParameter("@pAmount", rs.PaidAmount)); cmd.ExecuteNonQuery(); } InsertDbschemaInUSerDatabase(Convert.ToInt64(Session["RegID"].ToString()), 0); } catch (Exception ex) { // error handling var messege = ex.Message; return(Json(messege)); } finally { if (connectionState != ConnectionState.Closed) { conn.Close(); } } return(Json("Application deployed sucessfull")); } }
public ActionResult SecurityCode() { SecurityCode sc = new SecurityCode(); string oldcode = TempData["SecurityCode"] as string; string code = sc.CreateRandomCode(5); TempData["SecurityCode"] = code; return(File(sc.CreateValidateGraphic(code), "image/Jpeg")); }
public override int GetHashCode() { unchecked { int hashCode = (SecurityCode != null ? SecurityCode.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OptionNumber != null ? OptionNumber.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OptionCode != null ? OptionCode.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Bid.GetHashCode(); hashCode = (hashCode * 397) ^ BidVolume.GetHashCode(); hashCode = (hashCode * 397) ^ Ask.GetHashCode(); hashCode = (hashCode * 397) ^ AskVolume.GetHashCode(); hashCode = (hashCode * 397) ^ Volume.GetHashCode(); hashCode = (hashCode * 397) ^ Bid2.GetHashCode(); hashCode = (hashCode * 397) ^ BidVolume2.GetHashCode(); hashCode = (hashCode * 397) ^ Ask2.GetHashCode(); hashCode = (hashCode * 397) ^ AskVolume2.GetHashCode(); hashCode = (hashCode * 397) ^ Bid3.GetHashCode(); hashCode = (hashCode * 397) ^ BidVolume3.GetHashCode(); hashCode = (hashCode * 397) ^ Ask3.GetHashCode(); hashCode = (hashCode * 397) ^ AskVolume3.GetHashCode(); hashCode = (hashCode * 397) ^ Bid4.GetHashCode(); hashCode = (hashCode * 397) ^ BidVolume4.GetHashCode(); hashCode = (hashCode * 397) ^ Ask4.GetHashCode(); hashCode = (hashCode * 397) ^ AskVolume4.GetHashCode(); hashCode = (hashCode * 397) ^ Bid5.GetHashCode(); hashCode = (hashCode * 397) ^ BidVolume5.GetHashCode(); hashCode = (hashCode * 397) ^ Ask5.GetHashCode(); hashCode = (hashCode * 397) ^ AskVolume5.GetHashCode(); hashCode = (hashCode * 397) ^ (Greeks != null ? Greeks.GetHashCode() : 0); hashCode = (hashCode * 397) ^ OpenInterest.GetHashCode(); hashCode = (hashCode * 397) ^ Turnover.GetHashCode(); hashCode = (hashCode * 397) ^ UncoveredPositionQuantity.GetHashCode(); hashCode = (hashCode * 397) ^ PreviousSettlementPrice.GetHashCode(); hashCode = (hashCode * 397) ^ OpeningPrice.GetHashCode(); hashCode = (hashCode * 397) ^ AuctionReferencePrice.GetHashCode(); hashCode = (hashCode * 397) ^ AuctionReferenceQuantity.GetHashCode(); hashCode = (hashCode * 397) ^ HighestPrice.GetHashCode(); hashCode = (hashCode * 397) ^ LowestPrice.GetHashCode(); hashCode = (hashCode * 397) ^ LatestTradedPrice.GetHashCode(); hashCode = (hashCode * 397) ^ Change.GetHashCode(); hashCode = (hashCode * 397) ^ ChangePercentage.GetHashCode(); hashCode = (hashCode * 397) ^ PreviousClose.GetHashCode(); hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0); return(hashCode); } }
public SendUnlockCodeAuditMessage(User user, SecurityCode code) { AffectedEntity = new Entity { Type = UserTypeName, Id = user.Id }; Category = "UNLOCK"; Description = $"User {user.Email} (id: {user.Id}) has been sent an unlock code of {code.Code}"; }
public void ImplicitConversionToStringResultsInCorrectString() { const string code = "123"; var securityCode = SecurityCode.For(code); string result = securityCode; result.ShouldBe(code); }
public void ToStringReturnsCorrectFormat() { const string code = "123"; var securityCode = SecurityCode.For(code); var result = securityCode.ToString(); result.ShouldBe(code); }
public ActionResult Code() { string code = SecurityCode.MakeCode(5); MemoryStream ms = SecurityCode.CreateCodeImg(code); byte[] bytes = ms.ToArray(); Response.Cookies.Add(new HttpCookie("Code", code)); Session["Code"] = code; return(File(bytes, @"image/gif")); }
public ActionResult Edit([Bind(Include = "Id,Code,Flag")] SecurityCode securityCode) { if (ModelState.IsValid) { db.Entry(securityCode).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(securityCode)); }
public static SecurityCodeVM MToVM(SecurityCode model) { try { return(new SecurityCodeVM() { ID = model.ID.ToString(), API = model.API.ToString(), Code = model.Code, OwnerID = model.OwnerID }); } catch { return(null); } }
public override bool Equals(object obj) { if (obj == null || GetType() != obj.GetType()) { return(false); } OptionPair other = (OptionPair)obj; bool equals = SecurityCode.IgnoreCaseEquals(other.SecurityCode) && StrikePrice.AlmostEqual(other.StrikePrice) && Expiry == other.Expiry && PremiumMultiplier == other.PremiumMultiplier; return(equals); }
public async Task <bool> IsValidCode(int userId, string code) { SecurityCode sCode = await FindCodeAsync(userId); if (HasValidCode(sCode)) { if (sCode.Code == code) { DeleteCode(sCode); return(true); } } return(false); }
// GET: SecurityCodes/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SecurityCode securityCode = db.SecurityCodes.Find(id); if (securityCode == null) { return(HttpNotFound()); } return(View(securityCode)); }
public ActionResult Create([Bind(Include = "Id,Code,Flag")] SecurityCode securityCode) { securityCode.Flag = "Not Used"; if (ModelState.IsValid) { db.SecurityCodes.Add(securityCode); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(securityCode)); }
public bool Post([FromBody] EmailVerify _Obj) { try { int UserID = Convert.ToInt32(HttpContext.Current.User.Identity.Name); IntellidateR1.User GetUser = new IntellidateR1.User().GetUserDetails(UserID); bool _status = new SecurityCode().VerifyEmailStatus(UserID, _Obj.SCode, GetUser.EmailAddress); return(_status); } catch (Exception) { return(false); } }
public RequestChangeEmailAuditMessage(User user, SecurityCode code) { AffectedEntity = new Entity { Type = UserTypeName, Id = user.Id }; Category = "CHANGE_EMAIL"; Description = $"User {user.Email} (id: {user.Id}) has requested to change their email to {code.PendingValue}. They have been issued code {code.Code}"; ChangedProperties = new List <PropertyUpdate> { PropertyUpdate.FromString("SecurityCodes.Code", code.Code), PropertyUpdate.FromDateTime("SecurityCodes.ExpiryTime", code.ExpiryTime) }; }
private Security CreateSecurity() { var security = SecurityType.CreateInstance <Security>(); var code = SecurityCode.IsEmpty() ? DefaultSecurityCode : SecurityCode; security.Id = _idGenerator.GenerateId(code, Board); security.Code = code; security.Name = code; security.Board = Board; UpdateSecurity(security); return(security); }
public bool ValidateSecurityCode() { if (SecurityCode != null) { var securityCode = SecurityCode.Trim(); var status = int.TryParse(securityCode, out int result); if (status) { if (securityCode.Length == 3) { return(true); } } return(false); } return(true); }
public void SaveOrUpdate(SecurityCode entity) { _securityCodeRepository.SaveOrUpdate(entity); }
public void SaveChanges(SecurityCode entity) { _securityCodeRepository.SaveChanges(entity); }
public SecurityCode GetByExpression(SecurityCode entity) { return _securityCodeRepository.GetByExpression(x => x.PassCode.Equals(entity.PassCode)); }
public Guid Create(SecurityCode entity) { return _securityCodeRepository.Create(entity); }