当前位置: 动力学知识库 > 问答 > 编程问答 >

asp.net mvc - Validate User with Xamarin's Parse .NET API

问题描述:

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;
    }
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: