]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix log in with special password character (+)
authorChocobozzz <me@florianbigard.com>
Mon, 26 Mar 2018 09:49:44 +0000 (11:49 +0200)
committerChocobozzz <me@florianbigard.com>
Mon, 26 Mar 2018 09:49:44 +0000 (11:49 +0200)
client/src/app/core/auth/auth.service.ts
server.ts

index 8700e8c742b541026655decfd430630472e01ec2..f5ca2fcdc9d088c582702d286919082d2340ea3f 100644 (file)
@@ -112,17 +112,17 @@ export class AuthService {
 
   login (username: string, password: string) {
     // Form url encoded
-    const body = new HttpParams().set('client_id', this.clientId)
-                                 .set('client_secret', this.clientSecret)
-                                 .set('response_type', 'code')
-                                 .set('grant_type', 'password')
-                                 .set('scope', 'upload')
-                                 .set('username', username)
-                                 .set('password', password)
+    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 headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')
-
-    return this.http.post<UserLogin>(AuthService.BASE_TOKEN_URL, body, { headers })
+    return this.http.post<UserLogin>(AuthService.BASE_TOKEN_URL, body.toString(), { headers })
                     .map(res => Object.assign(res, { username }))
                     .flatMap(res => this.mergeUserInformation(res))
                     .map(res => this.handleLogin(res))
index c19ec4f194b7e01add2d3a112880af44cedf1734..56a4a0c443f8129e317c6ff3262254841e12e83c 100644 (file)
--- a/server.ts
+++ b/server.ts
@@ -88,11 +88,11 @@ app.use(morgan('combined', {
   stream: { write: logger.info.bind(logger) }
 }))
 // For body requests
+app.use(bodyParser.urlencoded({ extended: false }))
 app.use(bodyParser.json({
   type: [ 'application/json', 'application/*+json' ],
   limit: '500kb'
 }))
-app.use(bodyParser.urlencoded({ extended: false }))
 
 // ----------- Tracker -----------