X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fcore%2Fauth%2Fauth.service.ts;h=4213da20c065211f2468d23a4149d726dcb80be3;hb=cd4d7a2ca868209fb1e2dbd790c1e5d6cca77e86;hp=4b388d7be09097f7e03cd5b3b53693febc0b2fb8;hpb=db400f447a9f7aae1c56fa25396e93069744483f;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index 4b388d7be..4213da20c 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts @@ -11,6 +11,7 @@ import { environment } from '../../../environments/environment' import { RestExtractor } from '../../shared/rest' import { AuthStatus } from './auth-status.model' import { AuthUser } from './auth-user.model' +import { objectToUrlEncoded } from '@app/shared/misc/utils' interface UserLoginWithUsername extends UserLogin { access_token: string @@ -113,17 +114,18 @@ export class AuthService { login (username: string, password: string) { // Form url encoded - const body = new URLSearchParams() - body.set('client_id', this.clientId) - body.set('client_secret', this.clientSecret) - body.set('response_type', 'code') - body.set('grant_type', 'password') - body.set('scope', 'upload') - body.set('username', username) - body.set('password', password) + const body = { + client_id: this.clientId, + client_secret: this.clientSecret, + response_type: 'code', + grant_type: 'password', + scope: 'upload', + username, + password + } const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded') - return this.http.post(AuthService.BASE_TOKEN_URL, body.toString(), { headers }) + return this.http.post(AuthService.BASE_TOKEN_URL, objectToUrlEncoded(body), { headers }) .pipe( map(res => Object.assign(res, { username })), mergeMap(res => this.mergeUserInformation(res)),