 	response.render 'profile', options
 
 
-app.get '/action/logout', (request, response) ->
+app.get '/action/logout', mustBeAuthed, (request, response) ->
 	# TODO: move sessid to uonline{}
 	lib.user.closeSession dbConnection, request.cookies.sessid, (error, result) ->
 		if error?

		response.render 'register', options


app.get '/login/', (request, response) ->
	quickRender request, response, 'login'


app.post '/login/', (request, response) ->
	if lib.user.accessGranted.sync null, dbConnection, request.body.user, request.body.pass
		sessid = lib.user.createSession.sync null, dbConnection, request.body.user
		response.cookie 'sessid', sessid

	else
		response.redirect '/login/'

mustNotBeAuthed = (request, response, next) ->
	if request.uonline.basicOpts.loggedIn is true
		response.redirect config.defaultInstanceForUsers
	else
		next()


app.use ((request, response) ->
	# Read basic stuff
