I'm looking at one of the custom login controllers for communities and noticed this:

public static String login(String username, String password, String startUrl) {

        ApexPages.PageReference lgn = Site.login(username, password, startUrl);
        return null;
    catch (Exception ex) {
        system.debug('error message ' + ex.getMessage());
        return ex.getMessage();  

Basically, the user will enter in a username and password, and after they click "login" they will be redirected to the start url. Is there any documentation around aura.redirect?


2 Answers 2


No documentation can be found in Salesforce but it just works. The other issue I found is that for some reason test classes don't work well with them. Hence I include code like

if(!Test.isRunningTest()) { aura.redirect(lgn); }

so that I doesn't affect the test class and code coverage.


Ultimately moved away from aura.redirect and used window.location.href to sent the new endpoint. Once the apex controller finished, the callback function in the component redirected the user accordingly.

You must log in to answer this question.

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