Rewritten checking if user is active (less SQL queries by changing ORM flow to direct SQLs).