Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Branding login page not supported #63

Closed
abhijeetkokane opened this issue Feb 27, 2018 · 10 comments
Closed

Custom Branding login page not supported #63

abhijeetkokane opened this issue Feb 27, 2018 · 10 comments

Comments

@abhijeetkokane
Copy link

abhijeetkokane commented Feb 27, 2018

• Login working fine when we using default login page
• When we use custom branding login page
• It loads the login url in SFSafariViewController properly, but after click on login its redirects me to chatter page in same window, which is incorrect flow.
• In case of default login page, it redirects me to my application, which is correct flow.
• For custom branding we are using vfx page in backend.
• I need to implement custom branding login in my application and navigate to my application after click on login
Kindly can you guys help me with this.
Thanks in advance ...

@mike4aday
Copy link
Owner

@abhijeetkokane are you referring to custom branded communities login? If so, see issue #3 - if not, please provide a short, but clear, code sample to illustrate the issue.

@abhijeetkokane
Copy link
Author

Hi @mike4aday,

Thank you for your response.
Yes, we are using “custom branding” for community login. Following is the code which we are using for invoking the login functionality:

public func login(url: URL) throws {

guard !loggingIn else {
throw SalesforceError.invalidity(message: "Already logging in!")
}

guard let window = UIApplication.shared.keyWindow else {
throw SalesforceError.invalidity(message: "No valid window!")
}

// Replace current root view controller with Safari view controller for login
let loginVC = SafariLoginViewController(url: url)
loginVC.replacedRootViewController = window.rootViewController
window.rootViewController = loginVC
}

Below is the code for handle the callback for reedit into the app after successful login:

/// Handles the redirect URL returned by Salesforce after OAuth2 authentication and authorization.
/// Restores the root view controller that was replaced by the Salesforce-hosted login web form
/// - Parameter url: URL returned by Salesforce after OAuth2 authentication & authorization
public func handleRedirectURL(url: URL) {

var result:LoginResult

// Note: docs are wrong - error information may be in URL fragment or in query string...
if let urlEncodedString = url.fragment ?? url.query, let authData = AuthData(urlEncodedString: urlEncodedString) {
result = .success(authData)
}
else {
// Can't make sense of the redirect URL
result = .failure(SalesforceError.unsupportedURL(url: url))
}
salesforce.authManager.loginCompleted(result: result)

// Restore the original root view controller
////************************************************************
if let window = UIApplication.shared.keyWindow, let currentRootVC = window.rootViewController as? LoginViewController, let _ = currentRootVC.replacedRootViewController {

        let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
        let viewController = mainStoryboard.instantiateViewController(withIdentifier: "Home1")
        window.rootViewController = viewController
    }

}

I have noticed that, for login using default page, the callback method are getting invoked, but for the custom branding login page, the callback methods are not getting invoked.

@mike4aday
Copy link
Owner

@abhijeetkokane re. the code you included: is that the original Swiftly Salesforce code, or did you modify it? It's hard for me to tell if that is an as-is paste from Swiftly Salesforce source, or if you modified part(s). If modified, just include the modified segment(s).

Does the suggested workaround mentioned in issue #3 help?

@mike4aday
Copy link
Owner

@abhijeetkokane I'm closing this as no response - if it remains an issue, just reopen.

@abhijeetkokane
Copy link
Author

Hi @mike4aday 

Sorry for not replying for a while, but we are still facing the same issue:

We have added following in your sample project on git:

Login host url - https://spacecommunity-developer-edition.ap7.force.com/mycommunity

Consumer Key
3MVG9ZL0ppGP5UrCyn4nX.TOEnSFEhfQB8ntPSWhbgF_vr4AVm48FPHDSq561oMys7zqN8hA3I5qZ4AeetZAL

Consumer Secret
7900526202222258945

Following are the login credentials:

Email : harshal@harshal.com
Password: aress123$

After login using above credentials, it is not getting redirected to iOS app.

Could you please help us and look into this. After successful login the control should redirect to iOS app.

@mike4aday
Copy link
Owner

mike4aday commented Mar 8, 2018

Hi @abhijeetkokane have you tried the suggestion in issue #3 ?

(Also in keeping with security best practices, please don't post your credentials, like password, consumer secret -- I recommend changing all those that have been posted in this thread ASAP.)

@abhijeetkokane
Copy link
Author

Hi @mike4aday

We have tried your solution but no luck so far.
The credentials that we have provided are sample credentials for you to check the issue once.

Could you please let us know are you able to navigate back to app after login.

@mike4aday
Copy link
Owner

@abhijeetkokane what is the callback URL configured in the connected app?

@mike4aday mike4aday reopened this Mar 16, 2018
@abhijeetkokane
Copy link
Author

We have set the callback URL - "sfdc://success"

@mike4aday
Copy link
Owner

@abhijeetkokane is this still an issue? Please try with new version 7 and re-open if there's still a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants