diff --git a/src/app/core/auth/auth.service.ts b/src/app/core/auth/auth.service.ts index 09848d90449..5738948ebd3 100644 --- a/src/app/core/auth/auth.service.ts +++ b/src/app/core/auth/auth.service.ts @@ -42,7 +42,6 @@ import { UnsetUserAsIdleAction } from './auth.actions'; import { NativeWindowRef, NativeWindowService } from '../services/window.service'; -import { Base64EncodeUrl } from '../../shared/utils/encode-decode.util'; import { RouteService } from '../services/route.service'; import { EPersonDataService } from '../eperson/eperson-data.service'; import { getAllSucceededRemoteDataPayload } from '../shared/operators'; @@ -103,7 +102,7 @@ export class AuthService { */ public authenticate(user: string, password: string): Observable { // Attempt authenticating the user using the supplied credentials. - const body = (`password=${Base64EncodeUrl(password)}&user=${Base64EncodeUrl(user)}`); + const body = (`password=${encodeURIComponent(password)}&user=${encodeURIComponent(user)}`); const options: HttpOptions = Object.create({}); let headers = new HttpHeaders(); headers = headers.append('Content-Type', 'application/x-www-form-urlencoded'); diff --git a/src/app/shared/utils/encode-decode.util.spec.ts b/src/app/shared/utils/encode-decode.util.spec.ts deleted file mode 100644 index c3039c482e2..00000000000 --- a/src/app/shared/utils/encode-decode.util.spec.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Base64EncodeUrl } from './encode-decode.util'; - -describe('Encode/Decode Utils', () => { - const strng = '+string+/=t-'; - const encodedStrng = '%2Bstring%2B%2F%3Dt-'; - - it('should return encoded string', () => { - expect(Base64EncodeUrl(strng)).toBe(encodedStrng); - }); -}); diff --git a/src/app/shared/utils/encode-decode.util.ts b/src/app/shared/utils/encode-decode.util.ts deleted file mode 100644 index e21034b7bde..00000000000 --- a/src/app/shared/utils/encode-decode.util.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * use this to make a Base64 encoded string URL friendly, - * i.e. '+' and '/' are replaced with special percent-encoded hexadecimal sequences - * - * @param {String} str the encoded string - * @returns {String} the URL friendly encoded String - */ -export function Base64EncodeUrl(str): string { - return str.replace(/\+/g, '%2B').replace(/\//g, '%2F').replace(/\=/g, '%3D'); -}