public async Task <bool> RecoverPasswordAsync(RecoveryInfo recInfo) { string pwd = RandomPasswordGenerator.GeneratePassword(8); string hashPwd = _userManager.PasswordHasher.HashPassword(pwd); var update = Builders <User> .Update.Set(u => u.PasswordHash, hashPwd); User user = await _users.FindOneAndUpdateAsync(u => u.Email == recInfo.EmailAddress, update); if (user != null) { await Task.Factory.StartNew(() => { SmtpClient client = new SmtpClient() { Port = 25, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Host = ConfigurationManager.AppSettings.Get("smtpHost") }; MailMessage mail = new MailMessage(ConfigurationManager.AppSettings.Get("fromEmail"), user.Email) { Subject = "MRP Password Recovery", Body = String.Format("your temporary password is: {0}", pwd) }; client.Send(mail); }); return(true); } else { return(false); } }
public async Task <IHttpActionResult> RecoverPassword([FromBody] RecoveryInfo recInfo) { try { return(await _manager.RecoverPasswordAsync(recInfo) ? Ok() : (IHttpActionResult)BadRequest("no user found!")); } catch (Exception ex) { return(InternalServerError(ex)); } }
public void SetRecoveryInfo(RecoveryInfo recoveryInfo) { if (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["app:recoveryfiles_path"]) && recoveryInfo != null) { var filepath = string.Format("{0}/{1}.RecoveryInfo.json", System.Configuration.ConfigurationManager.AppSettings["app:recoveryfiles_path"], this.Uid); var json = JsonSerializer.Serialize <RecoveryInfo>(recoveryInfo); System.IO.File.WriteAllText(filepath, json); } }
/// <summary> /// 復元情報を記録します /// </summary> public static void SaveRecoveryInfo(RecoveryInfo info) { //列挙型を数値に変換して保存する PlayerPrefs.SetInt(recoveryInfoKey, (int)info); }
private void investigate( string strPath ) { string strStatus = ""; RecoveryInfo ri = new RecoveryInfo(); try { ri.gatherInfo( strPath ); if ( !ri.fHasWorkingInf ) strStatus += ", " + (ri.fHasInf ? "Skadad" : "Saknar") + " INF"; if ( !ri.fHasWorkingXml ) strStatus += ", " + (ri.fHasXml ? "Skadad" : "Saknar") + " SKOLA"; if ( !ri.fHasWorkingBk1 ) strStatus += ", " + (ri.fHasBk1 ? "Skadad" : "Saknar") + " BAK1"; if ( !ri.fHasWorkingBk2 ) strStatus += ", " + (ri.fHasBk2 ? "Skadad" : "Saknar") + " BAK2"; if ( strStatus.Length==0 ) strStatus = "OK"; else strStatus = strStatus.Substring(2); } catch ( Exception ex ) { strStatus = ex.Message; } ListViewItem lvi = lvWorks.Items.Add( Path.GetFileName(strPath) ); lvi.SubItems.Add( strStatus ); lvi.Tag = ri; }
public Task <bool> RecoverPasswordAsync(RecoveryInfo recInfo) { return(authRep.RecoverPasswordAsync(recInfo)); }