Login with email not UserName

A

andytidy

When using the membership, user and roles providers, what is a
straight forward way to get users to login using an email address and
not a username?
 
A

andytidy

When using the membership, user and roles providers, what is a
straight forward way to get users to login using an email address and
not a username?

OK, I just persisted on my search and found a simple enough answer:

Protected Sub AuthenticateLogin(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.AuthenticateEventArgs) Handles
Login1.Authenticate
'
Dim UserInfo As MembershipUser
Dim UserInfoColl As MembershipUserCollection
Dim sUserName As String
UserInfoColl = Membership.FindUsersByEmail(Login1.UserName)
sUserName = ""
For Each UserInfo In UserInfoColl
' Should only return one.
sUserName = UserInfo.UserName
Next
If Membership.ValidateUser(sUserName, Login1.Password) Then
e.Authenticated = True
Else
e.Authenticated = False
End If

End Sub


I'm sure there are better ways, and I will have a look at this later
(although any suggestions would be appreciated).
All I need to do now is find the best way to link this to my Staff
database.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top