本文整理汇总了C#中UserData.GenerateAuthenticationHash方法的典型用法代码示例。如果您正苦于以下问题:C# UserData.GenerateAuthenticationHash方法的具体用法?C# UserData.GenerateAuthenticationHash怎么用?C# UserData.GenerateAuthenticationHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserData
的用法示例。
在下文中一共展示了UserData.GenerateAuthenticationHash方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public ActionResult Create(Contact model)
{
int id = WebSecurity.GetUserId(WebSecurity.CurrentUserName);
var userProfile = _userContext.UserProfiles.First(x => x.UserId == id);
if (string.IsNullOrWhiteSpace(userProfile.PrivateKey) || string.IsNullOrWhiteSpace(userProfile.PublicKey))
{
TempData["Notification"] = new Notification("Please provide access keys that have been sent you by email", Nature.warning);
return RedirectToAction("Account", "Settings");
}
if (ModelState.IsValid)
{
UserData userData = new UserData();
userData.PublicKey = userProfile.PublicKey;
userData.Timestamp = DateTime.Now;
userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "POST/contact"+ userData.Timestamp + userProfile.PrivateKey);
ContactEndpoint c = new ContactEndpoint();
string message = c.CreateContact(model, userData);
TempData["Notification"] = new Notification("Contact has been added" + message, Nature.success);
Thread.Sleep(2500);
return RedirectToAction("Index");
} else
{
return View(model);
}
}
示例2: Delete
public ActionResult Delete(string id)
{
int userId = WebSecurity.GetUserId(WebSecurity.CurrentUserName);
var userProfile = _userContext.UserProfiles.First(x => x.UserId == userId);
UserData userData = new UserData();
userData.PublicKey = userProfile.PublicKey;
userData.Timestamp = DateTime.Now;
userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "DELETE/contact/" + id + userData.Timestamp + userProfile.PrivateKey);
ContactEndpoint c = new ContactEndpoint();
string message = c.DeleteContact(id, userData);
TempData["Notification"] = new Notification("Group has been removed" + message, Nature.success);
return RedirectToAction("Index");
}
示例3: Index
public ActionResult Index(string searchQuery, string searchScope, int? pageNumber, int pageSize = 12)
{
int id = WebSecurity.GetUserId(WebSecurity.CurrentUserName);
var userProfile = _userContext.UserProfiles.First(x => x.UserId == id);
searchScope = "all";
if (string.IsNullOrWhiteSpace(userProfile.PrivateKey) || string.IsNullOrWhiteSpace(userProfile.PublicKey))
{
TempData["Notification"] = new Notification("Please provide access keys that have been sent you by email", Nature.warning);
return RedirectToAction("Settings", "Account");
}
pageNumber = pageNumber ?? 1;
ContactEndpoint c = new ContactEndpoint();
UserData userData = new UserData();
userData.PublicKey = userProfile.PublicKey;
userData.Timestamp = DateTime.Now;
List<Contact> result;
if (string.IsNullOrWhiteSpace(searchQuery) || searchScope == null)
{
userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "GET/contact/" + pageNumber.Value + "/" + pageSize+"/false" + userData.Timestamp + userProfile.PrivateKey);
result = c.GetContacts(pageNumber.Value, pageSize, userData);
} else
{
userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "GET/contact/"+searchScope+"/"+searchQuery+"/" + pageNumber.Value + "/" + pageSize+"/false" + userData.Timestamp + userProfile.PrivateKey);
result = c.GetFilteredContacts(searchScope, searchQuery, pageNumber.Value, pageSize, userData);
}
ViewBag.SearchQuery = searchQuery;
return View(result);
}
示例4: GetContactsInGroupByAjax
public JsonResult GetContactsInGroupByAjax(string id /* group Id */)
{
int userId = WebSecurity.GetUserId(WebSecurity.CurrentUserName);
var userProfile = _userContext.UserProfiles.First(x => x.UserId == userId);
UserData userData = new UserData();
userData.PublicKey = userProfile.PublicKey;
userData.Timestamp = DateTime.Now;
userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "GET/contact/group/" + id + userData.Timestamp + userProfile.PrivateKey);
ContactEndpoint c = new ContactEndpoint();
var contact = c.GetContactsInGroup(id, userData);
return Json(contact, JsonRequestBehavior.AllowGet);
}
示例5: Edit
public ActionResult Edit(ContactViewModel model)
{
int userId = WebSecurity.GetUserId(WebSecurity.CurrentUserName);
var userProfile = _userContext.UserProfiles.First(x => x.UserId == userId);
model.contact.isContactGroup = false;
UserData userData = new UserData();
userData.PublicKey = userProfile.PublicKey;
userData.Timestamp = DateTime.Now;
userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "POST/contact/" + model.contact._id + userData.Timestamp + userProfile.PrivateKey);
ContactEndpoint c = new ContactEndpoint();
string message = c.UpdateContact(model.contact, userData);
TempData["Notification"] = new Notification("Contact has been modified" + message, Nature.success);
Thread.Sleep(2500);
return RedirectToAction("Index");
}
示例6: Edit
public ActionResult Edit(string id)
{
int userId = WebSecurity.GetUserId(WebSecurity.CurrentUserName);
var userProfile = _userContext.UserProfiles.First(x => x.UserId == userId);
UserData userData = new UserData();
userData.PublicKey = userProfile.PublicKey;
userData.Timestamp = DateTime.Now;
userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "GET/contact/" + id + userData.Timestamp + userProfile.PrivateKey);
GroupEndpoint g = new GroupEndpoint();
var group = g.GetGroup(id, userData);
return View(group);
}