| 
									
										
										
										
											2018-05-25 23:14:09 +05:30
										 |  |  | import dedent from 'dedent'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const ALLOWED_METHODS = ['GET']; | 
					
						
							|  |  |  | const EXCLUDED_PATHS = [ | 
					
						
							|  |  |  |   '/signout', | 
					
						
							| 
									
										
										
										
											2018-05-29 01:59:37 +05:30
										 |  |  |   '/accept-privacy-terms', | 
					
						
							| 
									
										
										
										
											2018-05-26 12:54:54 +01:00
										 |  |  |   '/update-email', | 
					
						
							| 
									
										
										
										
											2018-07-28 12:34:27 +05:30
										 |  |  |   '/confirm-email', | 
					
						
							| 
									
										
										
										
											2018-09-20 10:22:45 +01:00
										 |  |  |   '/passwordless-change' | 
					
						
							|  |  |  | ].reduce((list, item) => [...list, item, `/internal${item}`], []); | 
					
						
							| 
									
										
										
										
											2018-05-25 23:14:09 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | export default function emailNotVerifiedNotice() { | 
					
						
							|  |  |  |   return function(req, res, next) { | 
					
						
							|  |  |  |     if ( | 
					
						
							|  |  |  |       ALLOWED_METHODS.indexOf(req.method) !== -1 && | 
					
						
							|  |  |  |       EXCLUDED_PATHS.indexOf(req.path) === -1 | 
					
						
							|  |  |  |     ) { | 
					
						
							|  |  |  |       const { user } = req; | 
					
						
							|  |  |  |       if (user && (!user.email || user.email === '' || !user.emailVerified)) { | 
					
						
							|  |  |  |         req.flash( | 
					
						
							| 
									
										
										
										
											2018-05-31 01:35:24 +05:30
										 |  |  |           'info', | 
					
						
							| 
									
										
										
										
											2018-05-25 23:14:09 +05:30
										 |  |  |           dedent`
 | 
					
						
							|  |  |  |   New privacy laws now require that we have an email address where we can reach | 
					
						
							| 
									
										
										
										
											2018-06-21 04:51:08 +05:30
										 |  |  |   you. Please update your email address in the <a href='/settings'>settings</a> | 
					
						
							|  |  |  |   and click the link we send you to confirm. | 
					
						
							| 
									
										
										
										
											2018-05-25 23:14:09 +05:30
										 |  |  |           `
 | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return next(); | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | } |