/// <summary> /// Handles password reset request /// </summary> /// <param name="message"></param> protected virtual void HandlePasswordResetRequest(IIncommingMessage message) { var email = message.AsString(); var db = _database.AuthDatabase; var account = db.GetAccountByEmail(email); if (account == null) { message.Respond("No such e-mail in the system", ResponseStatus.Unauthorized); return; } var code = Util.CreateRandomString(4); db.SavePasswordResetCode(account, code); if (!_mailer.SendMail(account.Email, "Password Reset Code", string.Format(PasswordResetCode, code))) { message.Respond("Couldn't send an activation code to your e-mail"); return; } message.Respond(ResponseStatus.Success); }
public override void StartPlugin() { var result = scripts.ExecuteScript("return host.api.мукнуть('это полезно!')"); Logger.LogInformation("script result: {Result}", result); Logger.LogWarning("start tmp plugin {Guid}", Guid.NewGuid()); scripts.ExecuteScript("host.api.мукнуть('хрюката', 12)"); mail.SendMail("*****@*****.**", "Привет от коровы!", "Привет!\nЭто маленькая корова. У меня всё хорошо."); }
/// <summary> /// Handles password reset request /// </summary> /// <param name="message"></param> private void HandlePasswordResetRequest(IIncommingMessage message) { var email = message.AsString(); var account = _database.GetAccountByEmail(email); if (account == null) { message.Respond("No such e-mail in the system", ResponseStatus.Unauthorized); return; } var code = Util.CreateRandomString(4); _database.SavePasswordResetCode(account, code); _mailer.SendMail(account.Email, "Password Reset Code", string.Format(_config.PasswordResetEmailBody, code)); message.Respond(ResponseStatus.Success); }
private void HandleRequestPasswordResetCode(IClient client, Message message) { var data = message.Deserialize <RequestFromUserMessage>(); if (data != null) { var email = data.EMail; var account = _database.GetAccount(email); if (account == null) { return; } var code = Security.CreateRandomString(4); _database.SavePasswordResetCode(account, code); _mailPlugin.SendMail(account.Email, "Password Reset Code", string.Format(PasswordResetEmailBody, code)); } }