当前位置: 首页>>代码示例>>C#>>正文


C# UserData.GenerateAuthenticationHash方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:robertzur,项目名称:ContactBookWebClient,代码行数:30,代码来源:ContactController.cs

示例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");
        }
开发者ID:robertzur,项目名称:ContactBookWebClient,代码行数:18,代码来源:GroupController.cs

示例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);
        }
开发者ID:robertzur,项目名称:ContactBookWebClient,代码行数:33,代码来源:ContactController.cs

示例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);
        }
开发者ID:robertzur,项目名称:ContactBookWebClient,代码行数:15,代码来源:ContactController.cs

示例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");
        }
开发者ID:robertzur,项目名称:ContactBookWebClient,代码行数:19,代码来源:ContactController.cs

示例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);
        }
开发者ID:robertzur,项目名称:ContactBookWebClient,代码行数:16,代码来源:GroupController.cs


注:本文中的UserData.GenerateAuthenticationHash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。