As a preface, I'm fairly new to development in Lightning so apologies if this is a stupid question.

I'm working on a custom component to use in our community login page. I tried using "Site.login(username, password, url)" in my server-side controller but it doesn't seem to work. Is there something I could be missing with how to login using Lightning?


Component Controller "login" Function:

login : function(component) {
    // username and password passed from component
    var usernameValue = component.find("username");
    var passwordValue = component.find("password");

    // invocation of server-side login function
    var usernameFound = component.get("c.lightningLogin2");        
        username: usernameValue, 
        password: passwordValue

Apex Controller "lightningLogin2" Function:

public static void lightningLogin2 (String username, String password) {
    User u = Plexus_Utility.getUserDetails(username);
    if (u != null) {
        Site.login(username, password, '/s');

*"Plexus_Utility.getUserDetails(username);" returns a user if one is found

1 Answer 1


When I recently turned on communities this example controller (and a login form Lightning Component front) end was automatically added to the Developer Edition org:

global class LightningLoginFormController {


    public static String login(String username, String password, String startUrl) {
            ApexPages.PageReference lgn = Site.login(username, password, startUrl);
            return null;
        catch (Exception ex) {
            return ex.getMessage();            


so Site.login appears to be the way to go.

  • 2
    What is the Aura.redirect call in here? I can't find any documentation on a System.Aura class.
    – dsharrison
    Commented Aug 9, 2017 at 1:22
  • @dsharrison I can't find any documentation either. Perhaps worth asking a new question about that.
    – Keith C
    Commented Aug 9, 2017 at 7:09
  • Just of the reference, created a new question here: salesforce.stackexchange.com/questions/192673/…
    – Artur
    Commented Sep 19, 2017 at 10:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .