コード例 #1
0
 public static UserInfo FromString(string data)
 {
     var resultUser = new UserInfo();
     try
     {
         XElement element = XElement.Parse(data);
         resultUser.Id = int.Parse(element.Element("Id").Value);
         resultUser.FirstName = element.Element("FirstName").Value;
         resultUser.LastName = element.Element("LastName").Value;
         resultUser.Roles = element.Elements("Roles")
                                   .Elements("Role")
                                   .Select(p => p.Value)
                                   .ToArray();
     }
     catch (Exception ex)
     {
         new CustomAuthentication().SignOut();
         throw new ArgumentException("Invalid user name object!", ex);
     }
     return resultUser;
 }
コード例 #2
0
 private void SetAuthCookie(User user)
 {
     var userAuthInfo = new UserInfo(user);
     FormsAuthenticationTicket ticket = userAuthInfo.CreateTicket(false);
     new CustomAuthentication().SetAuthCookie(this.HttpContext, ticket);
 }