Example #1
0
        internal static OAuthUserIdentifyer GetUserIdentifyer(this HttpRequest request)
        {
            var ticket = request.GetFormsAuthenticationTicket();

            if (ticket != null)
            {
                var userIdent = new OAuthUserIdentifyer() { UserName = ticket.Name };

                if (!string.IsNullOrEmpty(ticket.UserData))
                {
                    try
                    {
                        userIdent.ServiceIdentifyer = ticket.UserData.Split('|')[0].FromJson<OAuthServiceIdentifyer>();
                    }
                    catch (Exception e){
                        throw new Exception("Looks like service identity data in user authetication cookie in the wrong format", e);
                    }
                }

                return userIdent;
            }
            else
            {
                return null;
            }
        }
Example #2
0
 internal static void SetUserIdentifyer(this HttpResponse response, OAuthUserIdentifyer UserIdentifyer)
 {
     response.SetAuthCookie(UserIdentifyer.UserName, true, UserIdentifyer.ServiceIdentifyer.AsJson());
 }