#!/bin/bash

menuLoginRequired()
{
	local app_name="$1"
	local username="$2"
	local password="$3"

	# Only show Traefik basic-auth creds when traefik is installed AND at
	# least one port has login=true AND traefik=true on the same row.
	local traefik_status=$(dockerCheckAppInstalled "traefik" "docker")
	local any_login="false"
	if [[ "$traefik_status" == "installed" ]]; then
		local i
		for i in "${!port_login_requireds[@]}"; do
			if [[ "${port_login_requireds[$i]}" == "true" \
			   && "${port_traefik_managed[$i]}" == "true" ]]; then
				any_login="true"
				break
			fi
		done
	fi

	if [[ "$any_login" == "true" ]]; then
		echo ""
		echo "    Website Authentication is setup for $app_name."
		echo ""
		echo "    Your login username is : $CFG_TRAEFIK_USER"
		echo "    Your password is : $CFG_TRAEFIK_PASS"
		echo ""
		echo "    (you always find them in the LibrePortal general config under CFG_TRAEFIK_USER/PASS)"
	fi
	if [[ "$username" != "" ]]; then
		echo ""
		echo "    Application login details are as follows for $app_name."
		echo ""
		echo "    Your login username is : $username"
		echo "    Your password is : $password"
	fi
	echo ""
}
