Added code for authentication and Logout. Not tested yet.