diff --git a/Web/Controllers/ControllerBase.cs b/Web/Controllers/ControllerBase.cs index 1a4898f..376fb2e 100644 --- a/Web/Controllers/ControllerBase.cs +++ b/Web/Controllers/ControllerBase.cs @@ -60,7 +60,10 @@ namespace MileageTraker.Web.Controllers protected string ResetPassword(User user) { - var passwordResetToken = Algorithms.GenerateToken(); + // don't make a new one if they already have an active token + var passwordResetToken = + user.PasswordResetToken ?? Algorithms.GenerateToken(); + var url = LinkForUrlAction( Url.Action("NewPassword", "Account", new NewPasswordViewModel diff --git a/Web/Controllers/UserController.cs b/Web/Controllers/UserController.cs index a705132..f74bbef 100644 --- a/Web/Controllers/UserController.cs +++ b/Web/Controllers/UserController.cs @@ -1,5 +1,7 @@ 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; @@ -147,6 +149,29 @@ namespace MileageTraker.Web.Controllers return View(viewModel); } + public JsonResult SendInvite(Guid userId) + { + var user = DataService.GetUser(userId); + var resetPasswordUrl = ResetPassword(user); + var email = new EmailNotificationService(); + email.SendInitializePassword(user, resetPasswordUrl); + return Json(true, JsonRequestBehavior.AllowGet); + } + + [Authorize(Roles = "Developer")] + public ActionResult InviteUninitialized() + { + var uninitializedUsers = + (from user in DataService.GetUsers() + where user.LastPasswordChangedDate == SqlDateTime.MinValue.Value + && user.LastActivityDate == SqlDateTime.MinValue.Value + && user.IsApproved + orderby user.Username + select user).ToList(); + + return View(uninitializedUsers); + } + public ActionResult Edit(Guid id) { var user = DataService.GetUser(id); diff --git a/Web/Scripts/Shared/Site.js b/Web/Scripts/Shared/Site.js index b38166d..e119340 100644 --- a/Web/Scripts/Shared/Site.js +++ b/Web/Scripts/Shared/Site.js @@ -224,4 +224,5 @@ $(function () { }); }); -/* End Form Validation */ \ No newline at end of file +/* End Form Validation */ + diff --git a/Web/Views/User/Index.cshtml b/Web/Views/User/Index.cshtml index f756278..b3d8420 100644 --- a/Web/Views/User/Index.cshtml +++ b/Web/Views/User/Index.cshtml @@ -20,6 +20,10 @@