diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-18 11:02:40 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-22 09:17:20 +0200 |
commit | cd4d7a2ca868209fb1e2dbd790c1e5d6cca77e86 (patch) | |
tree | a8d9e219c893551f669a3de37ae0ee91a6c0f7cd /client/src | |
parent | b4e5942ca79b8f5702c80197ec40eab8fa053a24 (diff) | |
download | PeerTube-cd4d7a2ca868209fb1e2dbd790c1e5d6cca77e86.tar.gz PeerTube-cd4d7a2ca868209fb1e2dbd790c1e5d6cca77e86.tar.zst PeerTube-cd4d7a2ca868209fb1e2dbd790c1e5d6cca77e86.zip |
Fix peertube with google bot
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/app/core/auth/auth.service.ts | 20 | ||||
-rw-r--r-- | client/src/app/shared/misc/utils.ts | 10 | ||||
-rw-r--r-- | client/src/assets/player/peertube-player.ts | 16 | ||||
-rw-r--r-- | client/src/standalone/videos/embed.ts | 3 |
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' | |||
11 | import { RestExtractor } from '../../shared/rest' | 11 | import { RestExtractor } from '../../shared/rest' |
12 | import { AuthStatus } from './auth-status.model' | 12 | import { AuthStatus } from './auth-status.model' |
13 | import { AuthUser } from './auth-user.model' | 13 | import { AuthUser } from './auth-user.model' |
14 | import { objectToUrlEncoded } from '@app/shared/misc/utils' | ||
14 | 15 | ||
15 | interface UserLoginWithUsername extends UserLogin { | 16 | interface 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 | ||
58 | function 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 |
59 | function objectToFormData (obj: any, form?: FormData, namespace?: string) { | 68 | function 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 | ||
102 | export { | 111 | export { |
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 @@ | |||
1 | import { VideoFile } from '../../../../shared/models/videos' | 1 | import { VideoFile } from '../../../../shared/models/videos' |
2 | 2 | ||
3 | import 'core-js/es6/symbol'; | ||
4 | import 'core-js/es6/object'; | ||
5 | import 'core-js/es6/function'; | ||
6 | import 'core-js/es6/parse-int'; | ||
7 | import 'core-js/es6/parse-float'; | ||
8 | import 'core-js/es6/number'; | ||
9 | import 'core-js/es6/math'; | ||
10 | import 'core-js/es6/string'; | ||
11 | import 'core-js/es6/date'; | ||
12 | import 'core-js/es6/array'; | ||
13 | import 'core-js/es6/regexp'; | ||
14 | import 'core-js/es6/map'; | ||
15 | import 'core-js/es6/weak-map'; | ||
16 | import 'core-js/es6/set'; | ||
17 | import 'core-js/es7/object'; | ||
18 | |||
3 | import 'videojs-hotkeys' | 19 | import 'videojs-hotkeys' |
4 | import 'videojs-dock' | 20 | import 'videojs-dock' |
5 | import './peertube-link-button' | 21 | import './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 @@ | |||
1 | import './embed.scss' | 1 | import './embed.scss' |
2 | 2 | ||
3 | // For google bot that uses Chrome 41 and does not understand fetch | ||
4 | import 'whatwg-fetch' | ||
5 | |||
3 | import * as videojs from 'video.js' | 6 | import * as videojs from 'video.js' |
4 | 7 | ||
5 | import { VideoDetails } from '../../../../shared' | 8 | import { VideoDetails } from '../../../../shared' |