Example #1
0
        public static bool TryParse(string payload, out HttpOnlyLoginCookieValue value)
        {
            value = null;

            var httpCookie = new HttpOnlyLoginCookieValue();
            var b          = new CookieValueReader(payload);

            bool ok = b.TryGetStringValue("lid", out httpCookie.LoginId) &&
                      b.TryGetLongValue("tuu", out httpCookie.TimeUntilUpdate) &&
                      b.TryGetLongValue("exp", out httpCookie.ExpirationDate) &&
                      b.TryGetStringValue("rhs", out httpCookie.RolesHash) &&
                      b.TryGetStringValue("hmc", out httpCookie.HMAC);

            if (ok)
            {
                value = httpCookie;
            }

            return(ok);
        }
Example #2
0
        public static bool TryParse(string payload, out UserAccessibleLoginCookieValue value)
        {
            value = null;

            var    userCookie = new UserAccessibleLoginCookieValue();
            var    b          = new CookieValueReader(payload);
            string csrfTokenStr;

            bool ok =
                b.TryGetStringValue("crf", out csrfTokenStr) &&
                b.TryGetIntValue("uid", out userCookie.UserId) &&
                b.TryGetStringValue("unm", out userCookie.Username);

            if (ok)
            {
                userCookie.CSRFToken = new CSRFToken(csrfTokenStr);
                value = userCookie;
            }

            return(ok);
        }