public ActionResult ConfirmEmail(string code) { var text = EmbedRsaCryptoService.XorDecryptSafeBase64(code); var frags = text.Split('|'); var userId = int.Parse(frags[0]); var userSrv = StaticServiceFactory.Create <IAspNetUserService>(); var user = userSrv.GetEntity(userId, null); bool result = false; if (String.Compare(user.Email, frags[1], true) == 0) { user.EmailConfirmed = true; userSrv.Save(user); result = true; } var msgSrv = StaticServiceFactory.Create <ISystemMessageService>(); string message = null; if (result) { message = msgSrv.GetByCode(SeatDomain.Constants.Messages.email_confirmed); } else { message = msgSrv.GetByCode(SeatDomain.Constants.Messages.email_not_confirmed); } return(View(message)); }
public ActionResult UnsubscribeMe(string signature) { var identity = EmbedRsaCryptoService.XorDecrypt(signature); var entity_id = int.Parse(identity.Split('-')[1]); var feedbackSrv = StaticServiceFactory.Create <IFeedBackService>(); var feedback = feedbackSrv.GetEntity(entity_id, null); feedback.Status = SeatDomain.Constants.FeedbackStates.InvalidResponse; feedbackSrv.Save(feedback); return(Content("OK")); }
public ActionResponse SendConfirmEmail(UserProfile profile) { var userSrv = ServiceFactory.Create <IAspNetUserService>(); var user = userSrv.GetCurrent(); if (!String.IsNullOrEmpty(profile.Email)) { user.Email = profile.Email; if (String.Compare(user.Email, profile.Email, true) != 0) { user.EmailConfirmed = false; } userSrv.Save(user); } if (String.IsNullOrEmpty(user.Email)) { return(new ActionResponse("آدرس ایمیل تنظیم نشده است.")); } profile.ResetChanges(); int sendCount = profile.EmailConfirmSendCount + 1; if (profile.EmailConfirmSendDt != null) { var time_diff = profile.EmailTimeDiff.Value; if (profile.EmailExceedWaitTimeLimit) { return(new ActionResponse(string.Format("برای ارسال مجدد تاییدیه ایمیل لطفا حداقل {0} ثانیه صبر نمایید.", (profile.EmailWaitTime.Value - DateTime.Now).TotalSeconds))); } if (profile.EmailExceedSendCountLimit) { return(new ActionResponse(string.Format("ارسال تاییدیه ایمیل بیشتر از {0} بار در طول یک روز امکانپذیر نمی باشد.", Constants.Notification.MaxCount))); } if (time_diff.TotalHours > 24) { sendCount = 1; } } var msgSrv = ServiceFactory.Create <ISystemMessageService>(); var subject = msgSrv.GetByCode(Constants.Messages.email_confirm_subject, Constants.SystemMessage.Media.Sms, null).FirstOrDefault()?.Text.Trim(); var body = msgSrv.GetByCode(Constants.Messages.email_confirm_body); var code = EmbedRsaCryptoService.XorEncryptSafeBase64(user.Id + "|" + user.Email); body = StringFormatUtility.ReplaceParams(body, new { username = user.UserName, code = code }, "[[", "]]"); var noty = ObjectRegistry.GetObject <INotificationProvider>(); var result = noty.VerifyEmail(subject, body, user.Email, true); if (result.Result == NotificationResultType.Success) { string username = user.UserName; Repository.BulkUpdate(x => username.Equals(x.Username, StringComparison.CurrentCultureIgnoreCase), x => new UserProfile { EmailConfirmSendDt = DateTime.Now, EmailConfirmSendCount = sendCount }); } return(new ActionResponse { Success = result.Result == NotificationResultType.Success, Message = result.Result == NotificationResultType.Success ? "تاییدیه آدرس ایمیل ارسال شد" : result.Message }); }
public Stream GetFile(string enc_file_path) { var file_path = EmbedRsaCryptoService.XorDecryptSafeBase64(enc_file_path); return(FileSystemProvider.Instance.FileStream(file_path, FileMode.Open, FileAccess.Read, FileShare.Read)); }