Created
May 6, 2020 18:43
-
-
Save rdehler/c8d429d918ce1392d23af1170da5caff to your computer and use it in GitHub Desktop.
Proof of concept to use a partial username or even another
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page id="loginPage" controller="CommunitiesLoginController" title="{!$Label.site.site_login}" showHeader="false"> | |
<apex:form> | |
<apex:pageMessages></apex:pageMessages> | |
Username: | |
<apex:inputText value="{!username}" /> | |
Password: | |
<apex:inputSecret value="{!password}" /> | |
<apex:commandButton action="{!customLogin}"/> | |
</apex:form> | |
</apex:page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global with sharing class CommunitiesLoginController { | |
global String username {get; set;} | |
global String password {get; set;} | |
global CommunitiesLoginController () {} | |
global PageReference customLogin() { | |
String actualUsername = username; | |
// here is where we would dynamically choose a field other than the username to retrieve the actual username | |
if (actualUsername != null && !actualUsername.contains('@')) { | |
actualUsername += '@7s-ray.dev'; | |
} | |
return Site.login(actualUsername, password, '/'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment