Add details to emails
A few clarifications
This commit is contained in:
@@ -158,9 +158,20 @@ namespace MileageTraker.Web.Controllers
|
||||
var email = new EmailNotificationService();
|
||||
var resetPasswordUrl = ResetPassword(user);
|
||||
email.SendResetPassword(user, resetPasswordUrl);
|
||||
TempData["StatusMessage"] = "Please check your email - we have sent a request for you to reset the password.";
|
||||
}
|
||||
|
||||
TempData["StatusMessage"] = "Please check your email - we have sent a request for you to reset the password.";
|
||||
else if (user == null)
|
||||
{
|
||||
TempData["StatusMessage"] = "Could not find username " + viewModel.Username + ".";
|
||||
TempData["StatusMessage-Type"] = "alert-error";
|
||||
return RedirectToAction("ResetPassword");
|
||||
}
|
||||
else if (!user.IsApproved)
|
||||
{
|
||||
TempData["StatusMessage"] = "Account is disabled for " + viewModel.Username + ".";
|
||||
TempData["StatusMessage-Type"] = "alert-error";
|
||||
}
|
||||
|
||||
// even when if not successful, let the user think they're getting a cookie
|
||||
return RedirectToAction("Login");
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Data.SqlTypes;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Security;
|
||||
using MileageTraker.Web.Attributes;
|
||||
@@ -149,6 +148,7 @@ namespace MileageTraker.Web.Controllers
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public JsonResult SendInvite(Guid userId)
|
||||
{
|
||||
var user = DataService.GetUser(userId);
|
||||
@@ -158,6 +158,17 @@ namespace MileageTraker.Web.Controllers
|
||||
return Json(true, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ActionResult SendResetPassword(Guid userId)
|
||||
{
|
||||
var user = DataService.GetUser(userId);
|
||||
var resetPasswordUrl = ResetPassword(user);
|
||||
var email = new EmailNotificationService();
|
||||
email.SendResetPassword(user, resetPasswordUrl);
|
||||
TempData["StatusMessage"] = "Reset password sent to User " + user.Username + " at " + user.Email;
|
||||
return RedirectToAction("Details", new { id = userId});
|
||||
}
|
||||
|
||||
[Authorize(Roles = "Developer")]
|
||||
public ActionResult InviteUninitialized()
|
||||
{
|
||||
|
||||
@@ -46,13 +46,13 @@ namespace MileageTraker.Web.Email
|
||||
/// <param name="url">Reset url</param>
|
||||
public void SendResetPassword(User user, string url)
|
||||
{
|
||||
var body = string.Format(_resetPasswordBody, url);
|
||||
var body = string.Format(_resetPasswordBody, url, user.Username);
|
||||
SendMessage(new MailMessage(_emaialFromAddress, user.Email, _resetPasswordSubject, body));
|
||||
}
|
||||
|
||||
public void SendInitializePassword(User user, string url)
|
||||
{
|
||||
var body = string.Format(_initializePasswordBody, url, user.FullName);
|
||||
var body = string.Format(_initializePasswordBody, url, user.FullName, user.Username);
|
||||
SendMessage(new MailMessage(_emaialFromAddress, user.Email, _initializePasswordSubject, body));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Web.Mvc;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using AutoMapper;
|
||||
using MileageTraker.Web.Utility;
|
||||
|
||||
namespace MileageTraker.Web.ViewModels.User
|
||||
{
|
||||
@@ -24,12 +25,17 @@ namespace MileageTraker.Web.ViewModels.User
|
||||
|
||||
static ExportUserViewModel()
|
||||
{
|
||||
Mapper.CreateMap<DateTime, string>()
|
||||
.ConvertUsing(dt =>
|
||||
dt.IsSqlMinValue()
|
||||
? string.Empty
|
||||
: dt.Date.ToString("d"));
|
||||
|
||||
Mapper.CreateMap<Models.User, ExportUserViewModel>()
|
||||
.ForMember(u => u.Roles,
|
||||
opt => opt.MapFrom(u =>
|
||||
string.Join((", "), u.Roles.Select(r => r.RoleName))));
|
||||
}
|
||||
|
||||
public ExportUserViewModel(Models.User user)
|
||||
{
|
||||
Mapper.Map(user, this);
|
||||
|
||||
@@ -117,7 +117,19 @@
|
||||
|
||||
<div class="btn-toolbar center-content">
|
||||
@Html.ActionLink("Edit", "Edit", new { id = Model.UserId }, new { @class = "btn" })
|
||||
@Html.ActionLink("Set Password", "SetPassword", new { id = Model.UserId }, new { @class = "btn" })
|
||||
<div class="btn-group">
|
||||
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
Password <span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
@Html.ActionLink("Send Password Reset Email", "SendResetPassword", new { userId = Model.UserId })
|
||||
</li>
|
||||
<li>
|
||||
@Html.ActionLink("Set Password", "SetPassword", new { id = Model.UserId })
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@if (Model.IsApproved)
|
||||
{
|
||||
@Html.ActionLink("Disable Account", "DisableUser", new {id = Model.UserId}, new {@class = "btn"})
|
||||
|
||||
+2
-2
@@ -15,9 +15,9 @@
|
||||
<add key="enableSimpleMembership" value="false" />
|
||||
<add key="EmailFromAddress" value="Mileage Traker <noreply@ethra.org>" />
|
||||
<add key="ResetPasswordSubject" value="New Password Request" />
|
||||
<add key="ResetPasswordBody" value="Please open this link to set a new password: {0}" />
|
||||
<add key="ResetPasswordBody" value="{1}, please open this link to set a new password for your Mileage Traker account: {0}" />
|
||||
<add key="InitializePasswordSubject" value="Initialize Mileage Traker Account" />
|
||||
<add key="InitializetPasswordBody" value="Hello {1}, please open this link to set up your password on Mileage Traker: {0}" />
|
||||
<add key="InitializetPasswordBody" value="Hello {1}, welcome to Mileage Traker. Your username is {2}. Please open this link to initialize your password: {0}" />
|
||||
</appSettings>
|
||||
<system.net>
|
||||
<mailSettings>
|
||||
|
||||
Reference in New Issue
Block a user