Accept admin password as bearer token for convenience
This commit is contained in:
		
							parent
							
								
									64a9d90b9a
								
							
						
					
					
						commit
						8ff434af75
					
				
							
								
								
									
										10
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								index.js
									
									
									
									
									
								
							@ -28,11 +28,15 @@ let results = [];
 | 
				
			|||||||
const voted = new Set();
 | 
					const voted = new Set();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function admin_only(req,res,next) {
 | 
					function admin_only(req,res,next) {
 | 
				
			||||||
    if (!req.session.admin) {
 | 
					    if (req.session.admin) {
 | 
				
			||||||
        return res.sendStatus(403)
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
	return next()
 | 
						return next()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (req.get('Authorization') == `Bearer ${admin_password}`) {
 | 
				
			||||||
 | 
						return next()
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return res.sendStatus(403)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function set_choices(new_choices, new_question) {
 | 
					function set_choices(new_choices, new_question) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user