问题描述:

I use Xamarin's Parse library using their .NET API. I want to implement my own membership provider inheriting from the MembershipProvider base class. When overriding ValidateUser method I use the following code:

public override bool ValidateUser(string username, string password)

{

try

{

ParseUser user = Task.Run(() => ParseUser.Query

.WhereEqualTo("username", username)

.WhereEqualTo("password", password)

.FirstOrDefaultAsync()).Result;

return user == null ? false : true;

}

catch (Exception)

{

return false;

}

}

but it seems that the API does not give you access to the user password. You can only set the password and not get it. Is there an alternative way to validate the user with user's provided username and password? Thank you.

网友答案:

You could use the built in Parse.LogIn method

public override bool ValidateUser(string username, string password)
{
    try 
    {
        currentUser = ParseUser.LogIn ("username", "password");
        return true;
    } catch (Exception ex) {
        return false;
    }
}
相关阅读:
Top