diff options
author | Chocobozzz <me@florianbigard.com> | 2021-12-03 17:04:47 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-12-03 17:04:47 +0100 |
commit | 0bc53e20296de68288481e2375b297626087174b (patch) | |
tree | a5d45a622932ee3539369dfeb9a84889176fd6f5 /server | |
parent | d1a233d8d86ead1e3aa2350d5480eab3336b17d6 (diff) | |
download | PeerTube-0bc53e20296de68288481e2375b297626087174b.tar.gz PeerTube-0bc53e20296de68288481e2375b297626087174b.tar.zst PeerTube-0bc53e20296de68288481e2375b297626087174b.zip |
Add ability to redirect users on external auth
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/api/config.ts | 12 | ||||
-rw-r--r-- | server/initializers/checker-before-init.ts | 1 | ||||
-rw-r--r-- | server/initializers/config.ts | 5 | ||||
-rw-r--r-- | server/lib/server-config-manager.ts | 5 | ||||
-rw-r--r-- | server/tests/api/check-params/config.ts | 12 | ||||
-rw-r--r-- | server/tests/api/server/config.ts | 18 |
6 files changed, 53 insertions, 0 deletions
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 805ad99c7..b253db397 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts | |||
@@ -169,6 +169,18 @@ function customConfig (): CustomConfig { | |||
169 | whitelisted: CONFIG.SERVICES.TWITTER.WHITELISTED | 169 | whitelisted: CONFIG.SERVICES.TWITTER.WHITELISTED |
170 | } | 170 | } |
171 | }, | 171 | }, |
172 | client: { | ||
173 | videos: { | ||
174 | miniature: { | ||
175 | preferAuthorDisplayName: CONFIG.CLIENT.VIDEOS.MINIATURE.PREFER_AUTHOR_DISPLAY_NAME | ||
176 | } | ||
177 | }, | ||
178 | menu: { | ||
179 | login: { | ||
180 | redirectOnSingleExternalAuth: CONFIG.CLIENT.MENU.LOGIN.REDIRECT_ON_SINGLE_EXTERNAL_AUTH | ||
181 | } | ||
182 | } | ||
183 | }, | ||
172 | cache: { | 184 | cache: { |
173 | previews: { | 185 | previews: { |
174 | size: CONFIG.CACHE.PREVIEWS.SIZE | 186 | size: CONFIG.CACHE.PREVIEWS.SIZE |
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts index 51c396548..c85c389cd 100644 --- a/server/initializers/checker-before-init.ts +++ b/server/initializers/checker-before-init.ts | |||
@@ -33,6 +33,7 @@ function checkMissedConfig () { | |||
33 | 'transcoding.resolutions.2160p', | 33 | 'transcoding.resolutions.2160p', |
34 | 'import.videos.http.enabled', 'import.videos.torrent.enabled', 'import.videos.concurrency', 'auto_blacklist.videos.of_users.enabled', | 34 | 'import.videos.http.enabled', 'import.videos.torrent.enabled', 'import.videos.concurrency', 'auto_blacklist.videos.of_users.enabled', |
35 | 'trending.videos.interval_days', | 35 | 'trending.videos.interval_days', |
36 | 'client.videos.miniature.prefer_author_display_name', 'client.menu.login.redirect_on_single_external_auth', | ||
36 | 'instance.name', 'instance.short_description', 'instance.description', 'instance.terms', 'instance.default_client_route', | 37 | 'instance.name', 'instance.short_description', 'instance.description', 'instance.terms', 'instance.default_client_route', |
37 | 'instance.is_nsfw', 'instance.default_nsfw_policy', 'instance.robots', 'instance.securitytxt', | 38 | 'instance.is_nsfw', 'instance.default_nsfw_policy', 'instance.robots', 'instance.securitytxt', |
38 | 'services.twitter.username', 'services.twitter.whitelisted', | 39 | 'services.twitter.username', 'services.twitter.whitelisted', |
diff --git a/server/initializers/config.ts b/server/initializers/config.ts index f3a7c6b6b..eb848be6b 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts | |||
@@ -63,6 +63,11 @@ const CONFIG = { | |||
63 | MINIATURE: { | 63 | MINIATURE: { |
64 | get PREFER_AUTHOR_DISPLAY_NAME () { return config.get<boolean>('client.videos.miniature.prefer_author_display_name') } | 64 | get PREFER_AUTHOR_DISPLAY_NAME () { return config.get<boolean>('client.videos.miniature.prefer_author_display_name') } |
65 | } | 65 | } |
66 | }, | ||
67 | MENU: { | ||
68 | LOGIN: { | ||
69 | get REDIRECT_ON_SINGLE_EXTERNAL_AUTH () { return config.get<boolean>('client.menu.login.redirect_on_single_external_auth') } | ||
70 | } | ||
66 | } | 71 | } |
67 | }, | 72 | }, |
68 | 73 | ||
diff --git a/server/lib/server-config-manager.ts b/server/lib/server-config-manager.ts index bdf6492f9..6aa459f82 100644 --- a/server/lib/server-config-manager.ts +++ b/server/lib/server-config-manager.ts | |||
@@ -47,6 +47,11 @@ class ServerConfigManager { | |||
47 | miniature: { | 47 | miniature: { |
48 | preferAuthorDisplayName: CONFIG.CLIENT.VIDEOS.MINIATURE.PREFER_AUTHOR_DISPLAY_NAME | 48 | preferAuthorDisplayName: CONFIG.CLIENT.VIDEOS.MINIATURE.PREFER_AUTHOR_DISPLAY_NAME |
49 | } | 49 | } |
50 | }, | ||
51 | menu: { | ||
52 | login: { | ||
53 | redirectOnSingleExternalAuth: CONFIG.CLIENT.MENU.LOGIN.REDIRECT_ON_SINGLE_EXTERNAL_AUTH | ||
54 | } | ||
50 | } | 55 | } |
51 | }, | 56 | }, |
52 | 57 | ||
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts index d0cd7722b..a6e87730a 100644 --- a/server/tests/api/check-params/config.ts +++ b/server/tests/api/check-params/config.ts | |||
@@ -54,6 +54,18 @@ describe('Test config API validators', function () { | |||
54 | whitelisted: true | 54 | whitelisted: true |
55 | } | 55 | } |
56 | }, | 56 | }, |
57 | client: { | ||
58 | videos: { | ||
59 | miniature: { | ||
60 | preferAuthorDisplayName: false | ||
61 | } | ||
62 | }, | ||
63 | menu: { | ||
64 | login: { | ||
65 | redirectOnSingleExternalAuth: false | ||
66 | } | ||
67 | } | ||
68 | }, | ||
57 | cache: { | 69 | cache: { |
58 | previews: { | 70 | previews: { |
59 | size: 2 | 71 | size: 2 |
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts index ea524723c..96ec17b0f 100644 --- a/server/tests/api/server/config.ts +++ b/server/tests/api/server/config.ts | |||
@@ -43,6 +43,9 @@ function checkInitialConfig (server: PeerTubeServer, data: CustomConfig) { | |||
43 | expect(data.services.twitter.username).to.equal('@Chocobozzz') | 43 | expect(data.services.twitter.username).to.equal('@Chocobozzz') |
44 | expect(data.services.twitter.whitelisted).to.be.false | 44 | expect(data.services.twitter.whitelisted).to.be.false |
45 | 45 | ||
46 | expect(data.client.videos.miniature.preferAuthorDisplayName).to.be.false | ||
47 | expect(data.client.menu.login.redirectOnSingleExternalAuth).to.be.false | ||
48 | |||
46 | expect(data.cache.previews.size).to.equal(1) | 49 | expect(data.cache.previews.size).to.equal(1) |
47 | expect(data.cache.captions.size).to.equal(1) | 50 | expect(data.cache.captions.size).to.equal(1) |
48 | expect(data.cache.torrents.size).to.equal(1) | 51 | expect(data.cache.torrents.size).to.equal(1) |
@@ -138,6 +141,9 @@ function checkUpdatedConfig (data: CustomConfig) { | |||
138 | expect(data.services.twitter.username).to.equal('@Kuja') | 141 | expect(data.services.twitter.username).to.equal('@Kuja') |
139 | expect(data.services.twitter.whitelisted).to.be.true | 142 | expect(data.services.twitter.whitelisted).to.be.true |
140 | 143 | ||
144 | expect(data.client.videos.miniature.preferAuthorDisplayName).to.be.true | ||
145 | expect(data.client.menu.login.redirectOnSingleExternalAuth).to.be.true | ||
146 | |||
141 | expect(data.cache.previews.size).to.equal(2) | 147 | expect(data.cache.previews.size).to.equal(2) |
142 | expect(data.cache.captions.size).to.equal(3) | 148 | expect(data.cache.captions.size).to.equal(3) |
143 | expect(data.cache.torrents.size).to.equal(4) | 149 | expect(data.cache.torrents.size).to.equal(4) |
@@ -246,6 +252,18 @@ const newCustomConfig: CustomConfig = { | |||
246 | whitelisted: true | 252 | whitelisted: true |
247 | } | 253 | } |
248 | }, | 254 | }, |
255 | client: { | ||
256 | videos: { | ||
257 | miniature: { | ||
258 | preferAuthorDisplayName: true | ||
259 | } | ||
260 | }, | ||
261 | menu: { | ||
262 | login: { | ||
263 | redirectOnSingleExternalAuth: true | ||
264 | } | ||
265 | } | ||
266 | }, | ||
249 | cache: { | 267 | cache: { |
250 | previews: { | 268 | previews: { |
251 | size: 2 | 269 | size: 2 |