 			# and finally call the callback
 			(callback true) if callback?
 			
+askForCredentials = (req, res) ->
+	res.type 'txt'
+	res.setHeader 'WWW-Authenticate', 'Basic realm="Please provide proper username and password to access this package"'
+	res.send 401, 'Please provide proper username and password to access this package'
+	
 app.all '/', (req, res) ->
 	callback = (username) ->
 		host = config.basePath ? "#{req.protocol}://#{req.header 'host'}"

					res.sendfile "#{config.packageFolder}/#{req.params[0]}/#{req.params[1].toLowerCase()}.tar", (err) -> res.send 404, '404 Not Found' if err?
				else
					logger.log "notice", "#{username} tried to download #{req.params[0]}/#{req.params[1].toLowerCase()}"
					res.setHeader 'WWW-Authenticate', 'Basic realm="Please provide proper username and password to access this package"'
					res.send 401, 'Please provide proper username and password to access this package'
			else
				res.send 404, '404 Not Found'
		

				else if result
					callback req.auth.username
				else
					askForCredentials req, res
		else
			askForCredentials req, res
	else
		callback ''

