Nearing feature complete for driver auth
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user