Nearing feature complete for driver auth

This commit is contained in:
2013-01-09 21:33:57 -05:00
parent 0b4c7914b3
commit bc019923d2
49 changed files with 609 additions and 335 deletions
+44
View File
@@ -1,6 +1,10 @@
using System;
using System.Web.Mvc;
using MileageTraker.Web.Attributes;
using MileageTraker.Web.DAL;
using MileageTraker.Web.Models;
using MileageTraker.Web.Utility;
using MileageTraker.Web.ViewModels.Account;
namespace MileageTraker.Web.Controllers
{
@@ -28,5 +32,45 @@ namespace MileageTraker.Web.Controllers
base.OnException(filterContext);
}
protected string GetCookieValue(string key)
{
return
HttpContext.Request.Cookies[key] != null
? HttpContext.Request.Cookies[key].Value
: null;
}
protected void SetCookieValue(string key, string value)
{
var cookies = HttpContext.Response.Cookies;
var httpCookie = cookies[key];
if (httpCookie == null) return;
httpCookie.Value = value;
httpCookie.Expires = DateTime.MaxValue;
}
protected string LinkForUrlAction(string urlAction)
{
return
string.Format("{0}://{1}{2}",
Request.Url.Scheme, Request.Url.Authority, urlAction);
}
protected string ResetPassword(User user)
{
var passwordResetToken = Algorithms.GenerateToken();
var url = LinkForUrlAction(
Url.Action("NewPassword", "Account",
new NewPasswordViewModel
{
UserId = user.UserId,
PasswordResetToken = passwordResetToken
}));
user.PasswordResetToken = passwordResetToken;
DataService.UpdateUser(user);
return url;
}
}
}