Skip to content

Commit

Permalink
cleaned up implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinosswald committed Mar 24, 2018
1 parent dc09590 commit eed45b8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
21 changes: 21 additions & 0 deletions angular-oauth2-oidc/src/encoder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {HttpParameterCodec} from '@angular/common/http';
/**
* This custom encoder allows charactes like +, % and / to be used in passwords
*/
export class WebHttpUrlEncodingCodec implements HttpParameterCodec {
encodeKey(k: string): string {
return encodeURIComponent(k);
}

encodeValue(v: string): string {
return encodeURIComponent(v);
}

decodeKey(k: string): string {
return decodeURIComponent(k);
}

decodeValue(v: string) {
return decodeURIComponent(v);
}
}
11 changes: 1 addition & 10 deletions angular-oauth2-oidc/src/oauth-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import { Subscription } from 'rxjs/Subscription';
import {HttpParameterCodec} from '@angular/common/http';

import { ValidationHandler, ValidationParams } from './token-validation/validation-handler';
import { UrlHelperService } from './url-helper.service';
import { OAuthEvent, OAuthInfoEvent, OAuthErrorEvent, OAuthSuccessEvent } from './events';
import { OAuthStorage, LoginOptions, ParsedIdToken, OidcDiscoveryDoc, TokenResponse, UserInfo } from './types';
import { b64DecodeUnicode } from './base64-helper';
import { AuthConfig } from './auth.config';
import { WebHttpUrlEncodingCodec } from './encoder';

/**
* Service for logging in and logging out with
Expand Down Expand Up @@ -561,15 +561,6 @@ export class OAuthService
*
* @stable
*/
class WebHttpUrlEncodingCodec implements HttpParameterCodec {
encodeKey(k: string): string { return encodeURIComponent(k); }

encodeValue(v: string): string { return encodeURIComponent(v); }

decodeKey(k: string): string { return decodeURIComponent(k); }

decodeValue(v: string) { return decodeURIComponent(v); }
}
let params = new HttpParams({encoder: new WebHttpUrlEncodingCodec() })
.set('grant_type', 'password')
.set('client_id', this.clientId)
Expand Down

0 comments on commit eed45b8

Please sign in to comment.