Allow to log in using email

Yehuda Lando asked on December 15, 2014 19:22

Hi,

I'm using Kentico 8.1, and I'm trying to log in using the email instead of the user name. I use this example: https://docs.kentico.com/display/K81/Handling+custom+external+authentication, and this is my code:

if (e.User == null)
{
    string username = SqlHelper.EscapeQuotes(e.UserName);
    string password = SqlHelper.EscapeQuotes(e.Password);

    var user =
        UserInfoProvider.GetUsers()
                .WhereEquals("Email", username)
                .WhereEquals("UserPassword", password)
                .FirstObject;

    e.User = user;
    e.UserName = user.UserName;
}

The right user is found and set, but my user is still not logged in. I can however see in event log the AUTHENTICATIONSUCC event for that user.

Is there another way to implement this?

Thanks

Correct Answer

Yehuda Lando answered on December 15, 2014 19:36

Ok, using custom providers helped me.

0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.