public ChangePasswordResult ChangeUserPassword(string newPassword, string oldPassword) { var parameters = new NameValueCollection() { { "userId", this.UserId } }; var pswdInfo = new UserPasswordInfo() { NewPasswordSalt = newPassword, OldPasswordSalt = oldPassword }; using (var content = HttpContentNetExtensions.CreateJsonNetDataContract <UserPasswordInfo>(pswdInfo)) { var template = UserManagementUriTemplates.BuildUriTemplate(UserManagementUriTemplates.ChagePassword); var response = SubmitRequest <ChangePasswordResponse>(template, parameters, "PUT", content); if (response.Code != ResponseCode.Ok) { throw new GroupdocsServiceException(response.ErrorMessage); } return(response.Result); } }
public static void Create(UserPasswordInfo userinfo) { //TODO exceli burada oluştur Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); Excel.Workbook xlWorkBook; Excel.Worksheet xlWorkSheet; object misValue = System.Reflection.Missing.Value; xlWorkBook = xlApp.Workbooks.Add(misValue); xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1); xlWorkSheet.Cells[1, 1] = "Application Name"; xlWorkSheet.Cells[1, 2] = "Email"; xlWorkSheet.Cells[1, 3] = "Username"; xlWorkSheet.Cells[2, 1] = userinfo.Application; xlWorkSheet.Cells[2, 3] = userinfo.UserName; xlWorkSheet.Cells[2, 2] = userinfo.Email; xlApp.DisplayAlerts = false; xlWorkBook.SaveAs("C:\\Users\\BaranOzsarac\\Documents\\EmailConfirmed_20191226_1340.xlsx", Excel.XlFileFormat.xlOpenXMLWorkbook, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue); xlWorkBook.Close(true, misValue, misValue); xlApp.Quit(); Marshal.ReleaseComObject(xlWorkSheet); Marshal.ReleaseComObject(xlWorkBook); Marshal.ReleaseComObject(xlApp); }
/// <summary> /// 更改密码 /// </summary> /// <param name="userid"></param> /// <param name="passwordtype"></param> /// <param name="password"></param> private void changePassword(int userid, Entity.passwordType passwordtype, string password, bool encrypt = true) { if (encrypt) { password = Utils.bitcmsMD5(password); } var passwordInfo = this.getUserPasswordInfo(userid, passwordtype); if (passwordInfo == null) { passwordInfo = new UserPasswordInfo() { UserId = userid, Password = password, PasswordType = passwordtype, LastDate = Config.SiteConfig.getLocalTime() }; this.dbContext.UserPassword.Add(passwordInfo); } else { passwordInfo.Password = password; passwordInfo.LastDate = Config.SiteConfig.getLocalTime(); } this.dbContext.SaveChanges(); }
public TestData(UserPasswordInfo userPasswordInfo, bool isRemoteSession, DateTime now, double expiryWarningDays, UserPasswordExpiryStatusInfo expectedUserPasswordExpiryStatusInfo) { UserPasswordInfo = userPasswordInfo; IsRemoteSession = isRemoteSession; Now = now; ExpiryWarningDays = expiryWarningDays; ExpectedUserPasswordExpiryStatusInfo = expectedUserPasswordExpiryStatusInfo; }
public ActionResult OfferHelp(int?id) { UserPasswordInfo info = db.UserPasswordInfos.Find(id); info.AuditStatus = 1; db.Entry(info).State = EntityState.Modified; db.SaveChanges(); return(View()); }
/*获取图片*/ public FileContentResult GetImage() { // SystemDbContext db = new SystemDbContext(); UserPasswordInfo info = new UserPasswordInfo(); if (info != null) { return(File(info.BusinessLicense, info.BusinessLicenseType));//File方法直接将二进制转化为指定类型了。 } else { return(null); } }
public bool SaveUserInfo(UserPasswordInfo userInfo) { if (StorageDictionary.ContainsKey(userInfo.UserId)) { // Log: existing user. // Question: Do we want to override user if password has expired? return(false); } StorageDictionary.Add(userInfo.UserId, userInfo); return(true); }
private bool CreatePasswordHash(string userId, string password) { // Compute hash var passwordHash = _cryptoService.HashPassword(password); // Save hash and salt. Only use salt to re-compute hash. var userInfo = new UserPasswordInfo { UserId = userId, HashedPassword = passwordHash.HashedPassword, HashSalt = passwordHash.HashSalt, Expiry = _passwordExpiryService.GenerateExpiryDate(), }; return(_passwordRepository.SaveUserInfo(userInfo)); }
public ActionResult ForgotPasswordApply(UserPasswordInfo info, HttpPostedFileBase image) { SystemDbContext db = new SystemDbContext(); if (ModelState.IsValid) { //UserPasswordInfo info = new UserPasswordInfo(); db.UserPasswordInfos.Add(info); if (image != null) { info.BusinessLicenseType = image.ContentType;//获取图片类型 //view.BusinessLicence = new byte[image.ContentLength];//新建一个长度等于图片大小的二进制地址 // image.InputStream.Read(view.BusinessLicence, 0, image.ContentLength);//将image读取到Logo中 info.BusinessLicense = new byte[image.ContentLength]; image.InputStream.Read(info.BusinessLicense, 0, image.ContentLength); } DateTime time = DateTime.Now; /*利用Expression表达式树可以解决:LINQ to Entities 不识别方法“System.DateTime AddMinutes(Double)*/ Expression <Func <UserPasswordInfo, bool> > where = p => p.UserName == info.UserName && (p.SubmitTime.AddMinutes(2) >= time); // var item = from p in db.UserPasswordInfos where (p.UserName == info.UserName && (p.SubmitTime.AddMinutes(2)<=time)) select p; var item = db.UserPasswordInfos.Where(where.Compile()).ToList(); if (item.Count() == 0) { /*审核状态字段*/ // info.AuditStatus = "ture"; info.SubmitTime = time; db.SaveChanges(); // return RedirectToAction("ForgotPasswordInfo"); return(RedirectToAction("ForgotPassword")); } else { return(RedirectToAction("ForgotPasswordInfoError")); } } return(View(info)); }
public ChangePasswordResult ChangeUserPassword(string userId, string newPassword, string oldPassword) { var parameters = new NameValueCollection() { { "callerId", this.UserId }, { "userId", userId } }; var pswdInfo = new UserPasswordInfo() { NewPasswordSalt = newPassword, OldPasswordSalt = oldPassword }; using (var content = HttpContentNetExtensions.CreateJsonNetDataContract<UserPasswordInfo>(pswdInfo)) { var template = UserManagementUriTemplates.BuildUriTemplate(UserManagementUriTemplates.ChageUserPassword); var response = SubmitRequest<ChangePasswordResponse>(template, parameters, "PUT", content); if (response.Code != ResponseCode.Ok) { throw new GroupdocsServiceException(response.ErrorMessage); } return response.Result; } }
public ActionResult ForgotPasswordApply() { UserPasswordInfo view = new UserPasswordInfo(); return(View(view)); }
public int ChangePassword(UserPasswordInfo Password) { return(_IUser.ChangePassword(int.Parse(base.User.Identity.Name), Password)); }
public override void OnAuthorization(AuthorizationContext filterContext) { filterContext.Controller.ViewBag.PasswordFlag = "false"; base.OnAuthorization(filterContext); var identity = filterContext.HttpContext.User.Identity; if (identity.IsAuthenticated) { if (!filterContext.IsChildAction && !filterContext.HttpContext.Request.IsAjaxRequest()) { var actionName = filterContext.ActionDescriptor.ActionName.ToUpper(); var controllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName.ToUpper(); var url = string.Format("{0}/{1}", controllerName, actionName); var anonymous = filterContext.ActionDescriptor.IsDefined(typeof(AllowAnonymousAttribute), false); if (!anonymous) { //if (string.IsNullOrEmpty(APIHelper.GetUserToken())) //{ // //redirect to login page if cookie and session are invalid // filterContext.HttpContext.Response.Redirect("~/Login", true); //} //else //{ //check page is authenticated var pageUrl = string.Format("System/HasPageQulification/?controller={0}&action={1}", controllerName, actionName); HttpResponseMessage responMessage = APIHelper.APIGetAsync(pageUrl); var message = JsonConvert.DeserializeObject <Message>(responMessage.Content.ReadAsStringAsync().Result); var result = (EnumAuthorize)Enum.Parse(typeof(EnumAuthorize), message.Content); switch (result) { case EnumAuthorize.PageNotAuthorized: filterContext.HttpContext.Response.Redirect("~/Home/UnauthorizedRequest", true); break; case EnumAuthorize.PageAuthorized: { int languageId = PISSessionContext.Current.CurrentWorkingLanguage.System_Language_UID; filterContext.Controller.ViewBag.PageID = url; #region Get pagetitle from session/db IEnumerable <SystemFunctionDTO> functions; if (filterContext.RequestContext.HttpContext.Session[SessionConstants.Functions] == null) { functions = JsonConvert.DeserializeObject <IEnumerable <SystemFunctionDTO> >( APIHelper.APIGetAsync("System/GetSystemValidFunctions").Content.ReadAsStringAsync().Result); filterContext.RequestContext.HttpContext.Session[SessionConstants.Functions] = functions; } else { functions = filterContext.RequestContext.HttpContext.Session[SessionConstants.Functions] as IEnumerable <SystemFunctionDTO>; } var target = functions.FirstOrDefault(q => q.URL == url && q.System_Language_UID == languageId && q.Table_ColumnName == "Function_Desc"); filterContext.Controller.ViewBag.PageTitle = target == null ? string.Empty : target.ResourceValue; if (filterContext.RequestContext.HttpContext.Session[SessionConstants.CurrentUserInfo] != null) { UserPasswordInfo dto = new UserPasswordInfo(); CurrentUser cu = new CurrentUser(); dto.UserId = PISSessionContext.Current.CurrentUser.Account_UID; if (cu.GetUserInfo.User_NTID.ToUpper() != "EQPUSER") { var changePassword = APIHelper.APIPostAsync(dto, "Settings/CheckAcountAPI").Content.ReadAsStringAsync().Result; filterContext.Controller.ViewBag.PasswordFlag = changePassword; } else { filterContext.Controller.ViewBag.PasswordFlag = "false"; } } else { filterContext.Controller.ViewBag.PasswordFlag = "false"; } #endregion } break; case EnumAuthorize.NotPageRequest: break; default: break; } } // } } } else { //Anonymous user, judge if controller allows anonymous access. var attr = filterContext.ActionDescriptor.GetCustomAttributes(true).OfType <AllowAnonymousAttribute>(); bool isAnonymous = attr.Any(a => a is AllowAnonymousAttribute); if (!isAnonymous) { filterContext.HttpContext.Response.Redirect("~/Login", true); } } }
public async Task GetApprovalOperations(ITurnContext <IMessageActivity> turnContext, PwdResetConversationStates conversationState, UserPasswordInfo userState, CancellationToken cancellationToken) { var approveText = turnContext.Activity.Text.Trim().ToLower(); //TODO: LUIS e input texti gönder.... var luisResult = await _luisRecognizer.RecognizeAsync(turnContext, cancellationToken); // onaylıyorum, tamam gibi intentler luise eklenebilir. if (luisResult.Intents.OrderBy(i => i.Value.Score).FirstOrDefault().Key == "Utilities_Confirm") { await turnContext.SendActivityAsync($"Sayın {userState.UserName}, {userState.Application} uygulaması için şifre reset talebiniz alınmıştır."); conversationState.CurrentState = PdwResetStates.Completed; Operations.ExcelCreator.Create(userState); } else if (luisResult.Intents.OrderBy(i => i.Value.Score).FirstOrDefault().Key == "Utilities_Cancel") { await turnContext.SendActivityAsync($"{userState.UserName} talebiniz iptal edilmiştir."); conversationState.CurrentState = PdwResetStates.Completed; } else { await turnContext.SendActivityAsync($"Sizi anlayamadım"); } }
private async Task InitialStateOperations(ITurnContext <IMessageActivity> turnContext, PwdResetConversationStates conversationState, UserPasswordInfo userState, CancellationToken cancellationToken) { var inputText = turnContext.Activity.Text.Trim().ToLower(); //TODO: LUIS e input texti gönder.... var luisResult = await _luisRecognizer.RecognizeAsync(turnContext, cancellationToken); if (luisResult.Intents.OrderBy(i => i.Value.Score).FirstOrDefault().Key == "SifreReset") { await turnContext.SendActivityAsync("Talebinizi gerçekleştirebilmemiz için aşağıdaki bilgileri doldurunuz."); Activity t = new Activity(); t.Type = ActivityTypes.Message; t.Attachments = new List <Attachment>() { CreateAdaptiveCardUsingJson() }; await turnContext.SendActivityAsync(t, cancellationToken); userState.Counter = 0; conversationState.CurrentState = PdwResetStates.GetInfo; } else if (luisResult.Intents.OrderBy(i => i.Value.Score).FirstOrDefault().Key == "Intent2") { userState.Counter = 0; await turnContext.SendActivityAsync("Bu konuyu yakın zamanda çözebilir hale geleceğim."); await turnContext.SendActivityAsync("Size başka bir konuda yardımcı olmamı ister misiniz?"); conversationState.CurrentState = PdwResetStates.Initial; } else { if (userState.Counter > 2) { await turnContext.SendActivityAsync("Belirttiğiniz konuda size yardımcı olamıyorum. Lütfen destek almak için 2222'yi arayınız."); //userState.Counter = 0; } else { await turnContext.SendActivityAsync("Sizi anlayamadım, şimdilik sadece şifre resetleme işleminizde yardımcı olabilirim."); userState.Counter++; } } }
private async Task <UserPasswordInfo> GetInfoOperations(ITurnContext <IMessageActivity> turnContext, PwdResetConversationStates conversationState, UserPasswordInfo userState) { UserPasswordInfo userStateFromAdaptiveCard = JsonConvert.DeserializeObject <UserPasswordInfo>(turnContext.Activity.Value.ToString()); // Kullanıcı adı validasyonu if (!UserNameValidator.Validate(userStateFromAdaptiveCard.UserName)) { await turnContext.SendActivityAsync("Kullanıcı adınızı hatalı girdiniz. Lütfen bilgileri tekrar giriniz"); userStateFromAdaptiveCard.Counter++; if (userStateFromAdaptiveCard.Counter < 3) { Activity t = new Activity(); t.Type = ActivityTypes.Message; t.Attachments = new List <Attachment>() { CreateAdaptiveCardUsingJson() }; await turnContext.SendActivityAsync(t); } else { await turnContext.SendActivityAsync("3 kez hatalı giriş yaptınız."); conversationState.CurrentState = PdwResetStates.Completed; } } else if (!EmailValidator.Validate(userStateFromAdaptiveCard.Email)) { await turnContext.SendActivityAsync("Email bilgisini hatalı girdiniz. Lütfen bilgileri tekrar giriniz"); userStateFromAdaptiveCard.Counter++; if (userStateFromAdaptiveCard.Counter < 3) { Activity t = new Activity(); t.Type = ActivityTypes.Message; t.Attachments = new List <Attachment>() { CreateAdaptiveCardUsingJson() }; await turnContext.SendActivityAsync(t); } else { await turnContext.SendActivityAsync("3 kez hatalı giriş yaptınız."); conversationState.CurrentState = PdwResetStates.Completed; } } else if (!ApplicationValidator.Validate(userStateFromAdaptiveCard.Application)) { await turnContext.SendActivityAsync("Application bilgisini hatalı girdiniz. Lütfen bilgileri tekrar giriniz"); userStateFromAdaptiveCard.Counter++; if (userStateFromAdaptiveCard.Counter < 3) { Activity t = new Activity(); t.Type = ActivityTypes.Message; t.Attachments = new List <Attachment>() { CreateAdaptiveCardUsingJson() }; await turnContext.SendActivityAsync(t); } else { await turnContext.SendActivityAsync("3 kez hatalı giriş yaptınız."); conversationState.CurrentState = PdwResetStates.Completed; } } else { await turnContext.SendActivityAsync($"{userStateFromAdaptiveCard.UserName} için şifreniz resetlenecektir. Onaylıyor musunuz?"); conversationState.CurrentState = PdwResetStates.GetApproval; } return(userStateFromAdaptiveCard); }