Skip to content

Instantly share code, notes, and snippets.

@ryanguest
Created October 16, 2012 22:09

Revisions

  1. ryanguest revised this gist Oct 16, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions MyLoginPage.apexp
    Original file line number Diff line number Diff line change
    @@ -18,5 +18,7 @@ apex:page controller="SiteLoginController" id="loginComponent" showheader="false
    </apex:form>

    If you're an employee, you can go here:

    <!-- NOTE: You will need to change this based on your community (currently hardcoded) -->
    <a href="https://login.salesforce.com//servlet/networks/session/create?portal=060D00000000XYT&amp;site=0DMD0000000054I&amp;inst=D">Log in here</a>
    </apex:page>
  2. ryanguest revised this gist Oct 16, 2012. 1 changed file with 23 additions and 0 deletions.
    23 changes: 23 additions & 0 deletions SiteLoginController.apex
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    /**
    * An apex page controller that exposes the site login functionality
    */
    global with sharing class SiteLoginController {
    global String username {get; set;}
    global String password {get; set;}

    global PageReference login() {
    String startUrl = System.currentPageReference().getParameters().get('startURL');
    return Site.login(username, password, startUrl);
    }

    global SiteLoginController () {}

    @IsTest(SeeAllData=true) global static void testSiteLoginController () {
    // Instantiate a new controller with all parameters in the page
    SiteLoginController controller = new SiteLoginController ();
    controller.username = '[email protected]';
    controller.password = '123456';

    System.assertEquals(controller.login(),null);
    }
    }
  3. ryanguest created this gist Oct 16, 2012.
    22 changes: 22 additions & 0 deletions MyLoginPage.apexp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    apex:page controller="SiteLoginController" id="loginComponent" showheader="false" standardStylesheets="false">

    <h1 style="color: gray"> Community Login </h1>

    <apex:form id="loginForm" forceSSL="true">
    <apex:outputPanel layout="block">
    <apex:pageMessages id="error"/>

    <apex:outputLabel value="{!$Label.site.username}" for="username"/>
    <apex:inputText id="username" value="{!username}"/>
    <apex:outputLabel value="{!$Label.site.password}" for="password"/>
    <apex:inputSecret id="password" value="{!password}"/>
    <apex:outputText value=""/>
    <apex:commandButton action="{!login}" value="{!$Label.site.login_button}" id="loginButton"/>


    </apex:outputPanel>
    </apex:form>

    If you're an employee, you can go here:
    <a href="https://login.salesforce.com//servlet/networks/session/create?portal=060D00000000XYT&amp;site=0DMD0000000054I&amp;inst=D">Log in here</a>
    </apex:page>