aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/core/auth/auth.service.ts20
-rw-r--r--client/src/app/shared/misc/utils.ts10
-rw-r--r--client/src/assets/player/peertube-player.ts16
-rw-r--r--client/src/standalone/videos/embed.ts3
4 files changed, 40 insertions, 9 deletions
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'
11import { RestExtractor } from '../../shared/rest' 11import { RestExtractor } from '../../shared/rest'
12import { AuthStatus } from './auth-status.model' 12import { AuthStatus } from './auth-status.model'
13import { AuthUser } from './auth-user.model' 13import { AuthUser } from './auth-user.model'
14import { objectToUrlEncoded } from '@app/shared/misc/utils'
14 15
15interface UserLoginWithUsername extends UserLogin { 16interface UserLoginWithUsername extends UserLogin {
16 access_token: string 17 access_token: string
@@ -113,17 +114,18 @@ export class AuthService {
113 114
114 login (username: string, password: string) { 115 login (username: string, password: string) {
115 // Form url encoded 116 // Form url encoded
116 const body = new URLSearchParams() 117 const body = {
117 body.set('client_id', this.clientId) 118 client_id: this.clientId,
118 body.set('client_secret', this.clientSecret) 119 client_secret: this.clientSecret,
119 body.set('response_type', 'code') 120 response_type: 'code',
120 body.set('grant_type', 'password') 121 grant_type: 'password',
121 body.set('scope', 'upload') 122 scope: 'upload',
122 body.set('username', username) 123 username,
123 body.set('password', password) 124 password
125 }
124 126
125 const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded') 127 const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')
126 return this.http.post<UserLogin>(AuthService.BASE_TOKEN_URL, body.toString(), { headers }) 128 return this.http.post<UserLogin>(AuthService.BASE_TOKEN_URL, objectToUrlEncoded(body), { headers })
127 .pipe( 129 .pipe(
128 map(res => Object.assign(res, { username })), 130 map(res => Object.assign(res, { username })),
129 mergeMap(res => this.mergeUserInformation(res)), 131 mergeMap(res => this.mergeUserInformation(res)),
diff --git a/client/src/app/shared/misc/utils.ts b/client/src/app/shared/misc/utils.ts
index b9aa223cf..79c93c1b3 100644
--- a/client/src/app/shared/misc/utils.ts
+++ b/client/src/app/shared/misc/utils.ts
@@ -55,6 +55,15 @@ function immutableAssign <A, B> (target: A, source: B) {
55 return Object.assign({}, target, source) 55 return Object.assign({}, target, source)
56} 56}
57 57
58function objectToUrlEncoded (obj: any) {
59 const str: string[] = []
60 for (const key of Object.keys(obj)) {
61 str.push(encodeURIComponent(key) + '=' + encodeURIComponent(obj[key]))
62 }
63
64 return str.join('&')
65}
66
58// Thanks: https://gist.github.com/ghinda/8442a57f22099bdb2e34 67// Thanks: https://gist.github.com/ghinda/8442a57f22099bdb2e34
59function objectToFormData (obj: any, form?: FormData, namespace?: string) { 68function objectToFormData (obj: any, form?: FormData, namespace?: string) {
60 let fd = form || new FormData() 69 let fd = form || new FormData()
@@ -100,6 +109,7 @@ function isInMobileView () {
100} 109}
101 110
102export { 111export {
112 objectToUrlEncoded,
103 getParameterByName, 113 getParameterByName,
104 populateAsyncUserVideoChannels, 114 populateAsyncUserVideoChannels,
105 getAbsoluteAPIUrl, 115 getAbsoluteAPIUrl,
diff --git a/client/src/assets/player/peertube-player.ts b/client/src/assets/player/peertube-player.ts
index f419d58fc..2e77a973f 100644
--- a/client/src/assets/player/peertube-player.ts
+++ b/client/src/assets/player/peertube-player.ts
@@ -1,5 +1,21 @@
1import { VideoFile } from '../../../../shared/models/videos' 1import { VideoFile } from '../../../../shared/models/videos'
2 2
3import 'core-js/es6/symbol';
4import 'core-js/es6/object';
5import 'core-js/es6/function';
6import 'core-js/es6/parse-int';
7import 'core-js/es6/parse-float';
8import 'core-js/es6/number';
9import 'core-js/es6/math';
10import 'core-js/es6/string';
11import 'core-js/es6/date';
12import 'core-js/es6/array';
13import 'core-js/es6/regexp';
14import 'core-js/es6/map';
15import 'core-js/es6/weak-map';
16import 'core-js/es6/set';
17import 'core-js/es7/object';
18
3import 'videojs-hotkeys' 19import 'videojs-hotkeys'
4import 'videojs-dock' 20import 'videojs-dock'
5import './peertube-link-button' 21import './peertube-link-button'
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts
index aa418d2d4..c88219242 100644
--- a/client/src/standalone/videos/embed.ts
+++ b/client/src/standalone/videos/embed.ts
@@ -1,5 +1,8 @@
1import './embed.scss' 1import './embed.scss'
2 2
3// For google bot that uses Chrome 41 and does not understand fetch
4import 'whatwg-fetch'
5
3import * as videojs from 'video.js' 6import * as videojs from 'video.js'
4 7
5import { VideoDetails } from '../../../../shared' 8import { VideoDetails } from '../../../../shared'