# dom/authenticate # **Description:** Ensures the user is logged in before accessing content pages. Otherwise, the browser is redirected back to the login page. > This module also does the following: * Appends the logout button to the header * Appends the "Report a Problem" button to the header, which mails the account specified in config.js * Adds the current username to the header bar * If the current page has a form, an "addedBy" hidden input is added to automatically populate the addedBy fact column ## Functions ## **quickforms.logout()** > Removes the userid cookie, and redirects the user back to the login page. ```javascript define(['helper/helper','dom/form/text'], function (){ var loginPage = "/"+quickforms.app+"/index.html" var username = getCookie('username'), userId = getCookie('userid'); if(isNull(username) && window.location.pathname != loginPage && !quickforms.offline) { window.location = loginPage; } else { var header = $('div[data-role="header"]'), logoutDiv = $('
'), logoutButton = $('Logout'), reportButton = $('Report a Problem'), topRightContainer = $('
'); topRightContainer.append(reportButton); topRightContainer.append(logoutButton); header.children().first().append(' - '+username); header.append (logoutDiv); logoutDiv.append(topRightContainer); header.trigger('create'); quickforms.form.domParsers.push(function(formObj){ var addedBy = $(''); var texObj = new quickforms.TextElement(addedBy,formObj); texObj.summary = function(){return '';}; texObj.parseDom(formObj); formObj.addChild(texObj); window.setTimeout(function(){formObj.finishedParsing();},1); }); } quickforms.logout = function() { setCookie('username','',1); window.location = loginPage; } }); ```