0

In Kentico, there is a login form with two textboxes (Email and Password).

Users already access the site by logging in via Email.

I need them to be able to access the site using UserName instead of Email. The username values are already present in the CMS_User table, column UserName.

rocky
  • 7,506
  • 3
  • 33
  • 48
krishnan
  • 33
  • 6
  • Is this what you were looking for? https://devnet.kentico.com/questions/-kentico-9-how-to-allow-e-mail-and-username-authentication-at-the-same-time – Subhash Jul 09 '19 at 14:22
  • In the kentico 10 site they have login box available. In the login box the current logic is able to access using Email id and Password. My requirements is how to allow E-Mail or Username authentication at the same time. – krishnan Jul 10 '19 at 07:24
  • Well, the link I provided before does talk about enabling email and username authentication at the same time, with a custom provider. What part of it does not fit your need? – Subhash Jul 10 '19 at 07:42
  • public LoginResult Login(LoginRequest request){ var validation = request.Validate(); if (validation != null) { return GetFailedLoginResult(validation.Name, resources.GetResourceString(validation.Error));} var user = kenticoUsers.GetUser(request.UserName); if (user == null || !kenticoUsers.UserIsInCurrentSite(user.UserId)) { return GetFailedLoginResult("loginEmail", resources.GetResourceString("Kadena.Logon.LogonFailed")); } return login.Login(request);} – krishnan Jul 10 '19 at 08:25
  • I using below codes – krishnan Jul 10 '19 at 08:25
  • publicLoginResult Login(LoginRequest loginRequest){var user=AuthenticationHelper.AuthenticateUser(loginRequest.LoginEmail, loginRequest.Password,SiteContext.CurrentSiteName);if (user != null){ChangeCookieExpiration(loginRequest.KeepLoggedIn);FormsAuthentication.SetAuthCookie(user.UserName, loginRequest.KeepLoggedIn);MembershipActivityLogger.LogLogin(user.UserName); return new LoginResult{LogonSuccess=true };}return new LoginResult{LogonSuccess=false,ErrorPropertyName="loginEmail",ErrorMessage=ResHelper.GetString("Kadena.Logon.LogonFailed", LocalizationContext. CurrentCulture.CultureCode)};} – krishnan Jul 10 '19 at 08:30

1 Answers1

0

Unless you're forcing a username to be an email address, the field can handle usernames which are not email addresses as well. When you register on the public site or create a user account in Kentico that is what makes the difference on what value is stored where.

When you register on the public site and don't have a specific username field, it will take the email address and place it as the username value.

Brenden Kehren
  • 5,919
  • 16
  • 27
  • In the kentico 10 site they have login box available. In the login box the current logic is able to access using Email id and Password. My requirements is how to allow E-Mail or Username authentication at the same time. – krishnan Jul 10 '19 at 07:23