main: eliminated authorization code duplication

Authorization status is also forwarded to html templates