Skip to content

Commit

Permalink
Merge pull request #262 from ringcentral/RCLABS-842
Browse files Browse the repository at this point in the history
Add loginHint param in loginUrl method
  • Loading branch information
SushilMallRC authored Jul 3, 2024
2 parents 49c9942 + 45e8e9b commit 1988419
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
31 changes: 30 additions & 1 deletion sdk/src/platform/Platform-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ describe('RingCentral.platform.Platform', () => {
).toEqual(
'http://whatever/restapi/oauth/authorize?response_type=code&redirect_uri=http%3A%2F%2Ffoo&client_id=whatever&state=&brand_id=&display=&prompt=&ui_options=foo&ui_options=bar&ui_locales=&localeId=&response_hint=baz&response_hint=quux',
);

expect(
platform.loginUrl({
implicit: false,
Expand All @@ -846,6 +846,35 @@ describe('RingCentral.platform.Platform', () => {
).toEqual(
'http://whatever/restapi/oauth/authorize?response_type=code&redirect_uri=http%3A%2F%2Ffoo&client_id=whatever&state=&brand_id=&display=&prompt=&ui_options=foo&ui_locales=&localeId=&response_hint=bar',
);

/**
* Test with loginHin parameter in loginUrl method
*/
expect(
platform.loginUrl({
implicit: false,
uiOptions: ['foo', 'bar'],
responseHint: ['baz', 'quux'],
loginHint: ['[email protected]','[email protected]'],
}),
).toEqual(
'http://whatever/restapi/oauth/authorize?response_type=code&redirect_uri=http%3A%2F%2Ffoo&client_id=whatever&state=&brand_id=&display=&prompt=&ui_options=foo&ui_options=bar&ui_locales=&localeId=&response_hint=baz&response_hint=quux&login_hint=rc%40xyz.com&login_hint=rc1%40xyz.com',
);

/**
* Test with loginHin parameter in loginUrl method
*/
expect(
platform.loginUrl({
implicit: false,
uiOptions: 'foo',
responseHint: 'bar',
loginHint: '[email protected]',
}),
).toEqual(
'http://whatever/restapi/oauth/authorize?response_type=code&redirect_uri=http%3A%2F%2Ffoo&client_id=whatever&state=&brand_id=&display=&prompt=&ui_options=foo&ui_locales=&localeId=&response_hint=bar&login_hint=rc%40xyz.com',
);

}),
);
});
Expand Down
6 changes: 6 additions & 0 deletions sdk/src/platform/Platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ export default class Platform extends EventEmitter {
usePKCE,
responseHint,
redirectUri,
loginHint,
}: LoginUrlOptions = {}) {
const query: AuthorizationQuery = {
response_type: implicit ? 'token' : 'code',
Expand All @@ -282,6 +283,9 @@ export default class Platform extends EventEmitter {
if (responseHint) {
query.response_hint = responseHint;
}
if (!!loginHint) {
query.login_hint = loginHint;
}
if (this._discovery) {
if (!this._discovery.initialized) {
throw new Error('Discovery is not initialized');
Expand Down Expand Up @@ -932,6 +936,7 @@ export interface LoginUrlOptions {
usePKCE?: boolean;
responseHint?: string | string[];
redirectUri?: string;
loginHint?: string | string[];
}

export enum LoginUrlPrompt {
Expand Down Expand Up @@ -977,6 +982,7 @@ export interface AuthorizationQuery {
code_challenge?: string;
code_challenge_method?: string;
discovery?: boolean;
login_hint?: string | string[];
}

export interface TokenRequestHeaders {
Expand Down

0 comments on commit 1988419

Please sign in to comment.