| 
									
										
										
										
											2020-10-27 11:27:17 +01:00
										 |  |  | 'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-06 18:03:56 +01:00
										 |  |  | module.exports = async (ctx, next) => { | 
					
						
							| 
									
										
										
										
											2021-09-13 12:03:12 +02:00
										 |  |  |   const pluginStore = strapi.store({ type: 'plugin', name: 'documentation' }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-06 18:03:56 +01:00
										 |  |  |   const config = await pluginStore.get({ key: 'config' }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!config.restrictedAccess) { | 
					
						
							| 
									
										
										
										
											2021-09-13 12:03:12 +02:00
										 |  |  |     return next(); | 
					
						
							| 
									
										
										
										
											2018-12-06 18:03:56 +01:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-18 12:38:21 +02:00
										 |  |  |   if (!ctx.session.documentation || !ctx.session.documentation.logged) { | 
					
						
							| 
									
										
										
										
											2018-12-06 18:03:56 +01:00
										 |  |  |     const querystring = ctx.querystring ? `?${ctx.querystring}` : ''; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-08 13:50:00 +02:00
										 |  |  |     return ctx.redirect( | 
					
						
							| 
									
										
										
										
											2021-07-20 12:12:30 +02:00
										 |  |  |       `${strapi.config.server.url}${ | 
					
						
							| 
									
										
										
										
											2024-03-11 12:28:46 +01:00
										 |  |  |         strapi.config.get('plugin::documentation.x-strapi-config').path | 
					
						
							| 
									
										
										
										
											2021-07-20 12:12:30 +02:00
										 |  |  |       }/login${querystring}`
 | 
					
						
							| 
									
										
										
										
											2020-05-08 13:50:00 +02:00
										 |  |  |     ); | 
					
						
							| 
									
										
										
										
											2018-12-06 18:03:56 +01:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Execute the action.
 | 
					
						
							| 
									
										
										
										
											2021-09-02 11:25:24 +02:00
										 |  |  |   return next(); | 
					
						
							| 
									
										
										
										
											2018-12-06 18:03:56 +01:00
										 |  |  | }; |