Exemplo n.º 1
0
    //sprawdzenie czy ciacho zawiera token
    public bool IsValidAuthCookie(HttpCookie cookie)
    {
        // Split the cookie value by the pipe delimiter.
        string[] values = cookie.Value.Split('|');
        if (values.Length != 2)
        {
            return(false);
        }

        // Retrieve the username and hash from the split values.
        string username    = values[0];
        string tokenSalted = values[1].ToUpper();

        // You'll have to provide your GetPasswordForUser function.
        string tokenUser = Usr.GetUserToken(username);
        string salt      = Usr.GetSaltFromUser(username);

        // Check the password and salt against the hash.
        return(IsMatchingHash(tokenSalted, CreateHash(tokenUser.ToUpper(), salt)));
    }