aboutsummaryrefslogtreecommitdiffhomepage
path: root/support/doc
diff options
context:
space:
mode:
Diffstat (limited to 'support/doc')
-rw-r--r--support/doc/plugins/guide.md27
1 files changed, 26 insertions, 1 deletions
diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md
index 36ade117b..a90f8e72b 100644
--- a/support/doc/plugins/guide.md
+++ b/support/doc/plugins/guide.md
@@ -20,6 +20,7 @@
20 - [Plugin static route](#plugin-static-route) 20 - [Plugin static route](#plugin-static-route)
21 - [Notifier](#notifier) 21 - [Notifier](#notifier)
22 - [Markdown Renderer](#markdown-renderer) 22 - [Markdown Renderer](#markdown-renderer)
23 - [Auth header](#auth-header)
23 - [Custom Modal](#custom-modal) 24 - [Custom Modal](#custom-modal)
24 - [Translate](#translate) 25 - [Translate](#translate)
25 - [Get public settings](#get-public-settings) 26 - [Get public settings](#get-public-settings)
@@ -203,7 +204,7 @@ function register ({
203} 204}
204``` 205```
205 206
206You can also store files in the plugin data directory (`/{plugins-directory}/data/{npm-plugin-name}`). 207You can also store files in the plugin data directory (`/{plugins-directory}/data/{npm-plugin-name}`) **in PeerTube >= 3.2**.
207This directory and its content won't be deleted when your plugin is uninstalled/upgraded. 208This directory and its content won't be deleted when your plugin is uninstalled/upgraded.
208 209
209```js 210```js
@@ -526,6 +527,30 @@ function register (...) {
526} 527}
527``` 528```
528 529
530#### Auth header
531
532**PeerTube >= 3.2**
533
534To make your own HTTP requests using the current authenticated user, use an helper to automatically set appropriate headers:
535
536```js
537function register (...) {
538 registerHook({
539 target: 'action:auth-user.information-loaded',
540 handler: ({ user }) => {
541
542 // Useless because we have the same info in the ({ user }) parameter
543 // It's just an example
544 fetch('/api/v1/users/me', {
545 method: 'GET',
546 headers: peertubeHelpers.getAuthHeader()
547 }).then(res => res.json())
548 .then(data => console.log('Hi %s.', data.username))
549 }
550 })
551}
552```
553
529#### Custom Modal 554#### Custom Modal
530 555
531To show a custom modal: 556To show a custom modal: