Ejemplo n.º 1
0
        /// <summary>
        /// Gets the system identification key from FormsAuthenticationTicket
        /// </summary>
        /// <param name="ticket"></param>
        /// <returns></returns>
        public static List <string> Roles(this FormsAuthenticationTicket ticket)
        {
            NameValueCollection userData = ticket.GetUserData();
            List <string>       roles    = CommonHelper.SplitString(userData[ROLES]);

            return(roles);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Determines if the role is contained with the ticket
        /// </summary>
        /// <param name="ticket"></param>
        /// <param name="role"></param>
        /// <returns></returns>
        private static bool IsInRole(this FormsAuthenticationTicket ticket, string role)
        {
            NameValueCollection userData = ticket.GetUserData();
            var ticketRoles = CommonHelper.SplitString(userData[ROLES]);

            return(ticketRoles.Contains(role));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets the Facebook access token from FormsAuthenticationTicket
 /// </summary>
 /// <param name="ticket"></param>
 /// <returns></returns>
 public static string AccessToken(this FormsAuthenticationTicket ticket)
 {
     return(ticket.GetUserData()[ACCESS_TOKEN]);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets the system identification key from FormsAuthenticationTicket
 /// </summary>
 /// <param name="ticket"></param>
 /// <returns></returns>
 public static Guid IdKey(this FormsAuthenticationTicket ticket)
 {
     return(new Guid(ticket.GetUserData()[ID_KEY]));
 }