Skip to content

Commit 9c3e319

Browse files
author
ahaslehurst
committed
Pass custom query parameters to code flow
1 parent 7feca76 commit 9c3e319

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

projects/lib/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"name": "angular-oauth2-oidc",
2+
"name": "@westfieldhealth/angular-oauth2-oidc",
33
"license": "MIT",
44
"author": {
55
"name": "Manfred Steyer"
66
},
7-
"version": "8.0.1",
7+
"version": "1.0.1",
88
"repository": "manfredsteyer/angular-oauth2-oidc",
99
"dependencies": {
1010
"jsrsasign": "^8.0.12"

projects/lib/src/interceptors/default-oauth.interceptor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class DefaultOAuthInterceptor implements HttpInterceptor {
5050
if (!this.moduleConfig.resourceServer) {
5151
return next.handle(req);
5252
}
53-
if (this.moduleConfig.resourceServer.allowedUrls && !this.checkUrl(url)) {
53+
if (!this.checkUrl(url)) {
5454
return next.handle(req);
5555
}
5656

projects/lib/src/oauth-service.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
13731373
*/
13741374
public tryLogin(options: LoginOptions = null): Promise<boolean> {
13751375
if (this.config.responseType === 'code') {
1376-
return this.tryLoginCodeFlow().then(_ => true);
1376+
return this.tryLoginCodeFlow(options).then(_ => true);
13771377
}
13781378
else {
13791379
return this.tryLoginImplicitFlow(options);
@@ -1391,13 +1391,13 @@ export class OAuthService extends AuthConfig implements OnDestroy {
13911391
}
13921392

13931393
return this.urlHelper.parseQueryString(queryString);
1394-
1395-
13961394
}
13971395

1398-
public tryLoginCodeFlow(): Promise<void> {
1396+
public tryLoginCodeFlow(options: LoginOptions = null): Promise<void> {
13991397

1400-
const parts = this.parseQueryString(window.location.search)
1398+
const parts = this.parseQueryString(options.customQuery
1399+
? options.customQuery
1400+
: window.location.search);
14011401

14021402
const code = parts['code'];
14031403
const state = parts['state'];
@@ -1415,7 +1415,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
14151415

14161416
if (parts['error']) {
14171417
this.debug('error trying to login');
1418-
this.handleLoginError({}, parts);
1418+
this.handleLoginError(options, parts);
14191419
const err = new OAuthErrorEvent('code_error', {}, parts);
14201420
this.eventsSubject.next(err);
14211421
return Promise.reject(err);

projects/lib/src/types.ts

+6
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ export class LoginOptions {
4848
* anymore in the url. If not, set this to true.
4949
*/
5050
preventClearHashAfterLogin? = false;
51+
52+
/**
53+
* A custom query string to be used instead of the
54+
* actual one.
55+
*/
56+
customQuery?: string;
5157
}
5258

5359
/**

0 commit comments

Comments
 (0)