-
Notifications
You must be signed in to change notification settings - Fork 695
Adds a new configuration option to allow external control over how the login page is opened #235
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
Adds a new configuration option to allow external control over how the login page is opened #235
Conversation
Currently have the same problem in an application I'm working on: We're using Ionic 3 with I think returning the /**
* Starts the implicit flow and redirects to user to
* the auth servers login url.
*
* @param additionalState Optinal state that is passes around.
* You find this state in the property ``state`` after ``tryLogin`` logged in the user.
* @param params Hash with additional parameter. If it is a string, it is used for the
* parameter loginHint (for the sake of compatibility with former versions)
* @param noRedirectToLoginUrl If a login url is configured, the user is redirected to it.
*/
initImplicitFlowInternal(additionalState = '', params: string | object = '', noRedirectToLoginUrl = false): Promise<string> {
if (this.inImplicitFlow) {
return;
}
this.inImplicitFlow = true;
if (!this.validateUrlForHttps(this.loginUrl)) {
throw new Error('loginUrl must use Http. Also check property requireHttps.');
}
let addParams: object = {};
let loginHint: string = null;
if (typeof params === 'string') {
loginHint = params;
}
else if (typeof params === 'object') {
addParams = params;
}
return this.createLoginUrl(additionalState, loginHint, null, false, addParams).then((url) => {
if (noRedirectToLoginUrl) {
return url;
}
location.href = url;
})
.catch(error => {
console.error('Error in initImplicitFlow');
console.error(error);
this.inImplicitFlow = false;
return null;
});
}; |
@GFoley83 Just a note on the parameter name. I'd be more inclined to have the parameter the other way round. i.e. redirectToLoginUrl and default it to true. I was looking at implementing this as an ImplicitFlowMethod config option, to allow options redirect, none, iframe and newWindow, and baking the code the iframe and new window into the library, but it probably makes more sense to just allow returning the url and letting the user handle it as desired. |
thx |
@nhance Can you please provide an example of how you're using this with inappbrowser? I have a similar use case. |
If I understand it right, he is calling |
Documentation would be awesome. 😉
… On May 15, 2018, at 19:55, Manfred Steyer ***@***.***> wrote:
If I understand it right, he is calling initImplicitFlow with this new flag. This causes the method to just return a promise with an url. This url can be set manually in the inappbrowser.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@mraible You can now provide It is expected to be a function with a single parameter Here's an example:
|
It appears this is not actually merged in. We will create a new pull request to actually implement this |
Calling openUri here seems to work, @manfredsteyer could you change this? |
In my implementation I was having trouble getting this to work on device due to the need to use an inappbrowser to open and catch the redirect_uri. This method allows implementations to configure a function for opening the tryLogin url.
New AuthConfig option:
openUri: (uri: string) => void)
This method will be called when attempting to login via implicit flow.