Put ban queries to functions, implement auth check