Overriding ValidateUser () with SqlMembershipProvider and Custom SQL Database

I want to use an SQL database that is already in use on my network, so I wrote code to override ValidateUser():

public override bool ValidateUser(string username, string password)
{
    return true;
}

I set this so that it returns true without checking my database, just to test its theory.

Is that all I need to do, or is there something else for it to work correctly with other functions, for example, storing information about the username so that later it can be found, or is it just that I just store this information in a session variable?

As soon as the function returns true, the user is authenticated?

+1
source share
1

, SqlmembershipProvider.

ValidateUser (, ), ( cookie) Membership.GetUser.

:

public override bool ValidateUser(string username, string password)
{
    // check in database with SqlmembershipProvider
    bool isValid = base.ValidateUser(username, password);
    // get user from database
    var user = Membership.GetUser(username);
    if(isValid)
    {
        // ...
    }
    else{
        // log wrong attempt if you want
    }
    return isValid;
}
+1

Source: https://habr.com/ru/post/1656716/


All Articles