mirror of
				https://github.com/StefBuwalda/cal_counter.git
				synced 2025-10-30 11:19:59 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			32 lines
		
	
	
		
			848 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			848 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from flask_login import current_user
 | |
| from flask import redirect, url_for, flash
 | |
| from typing import Optional
 | |
| from zoneinfo import ZoneInfo
 | |
| 
 | |
| 
 | |
| def login_required():
 | |
|     if not current_user.is_authenticated:
 | |
|         return redirect(url_for("auth.login"))
 | |
|     if current_user.must_change_password:
 | |
|         flash("You have to change your password")
 | |
|         return redirect(url_for("auth.change_password"))
 | |
|     return
 | |
| 
 | |
| 
 | |
| def default_return(next_page: Optional[str] = None):
 | |
|     return redirect(url_for("user.daily_log2"))
 | |
|     if next_page:
 | |
|         return redirect(next_page)
 | |
|     if current_user.is_admin:
 | |
|         return redirect(url_for("admin.food_items"))
 | |
|     return redirect(url_for("dashboard"))
 | |
| 
 | |
| 
 | |
| def is_valid_timezone(tz: str) -> bool:
 | |
|     try:
 | |
|         ZoneInfo(tz)
 | |
|     except Exception:
 | |
|         print(Exception)
 | |
|         return False
 | |
|     return True
 |