Add support email to .env to show in client application (#353)

This commit is contained in:
Leendert de Borst
2024-11-11 18:05:59 +01:00
parent 250ab24654
commit ec84792034
7 changed files with 55 additions and 4 deletions

View File

@@ -81,6 +81,7 @@ Here is an example file with the various options explained:
{
"ApiUrl": "http://localhost:5092",
"PrivateEmailDomains": ["example.tld"],
"SupportEmail": "support@example.tld",
"UseDebugEncryptionKey": "true",
"CryptographyOverrideType" : "Argon2Id",
"CryptographyOverrideSettings" : "{\"DegreeOfParallelism\":1,\"MemorySize\":1024,\"Iterations\":1}"

View File

@@ -245,6 +245,30 @@ set_smtp_tls_enabled() {
fi
}
# Function to ask for support email
set_support_email() {
printf "${CYAN}> Setting SUPPORT_EMAIL...${NC}\n"
if ! grep -q "^SUPPORT_EMAIL=" "$ENV_FILE"; then
printf "Please enter the support email address that users can contact for issues accessing their vault (press Enter to disable): "
read -r support_email
echo "SUPPORT_EMAIL=${support_email}" >> "$ENV_FILE"
if [ -z "$support_email" ]; then
printf "${GREEN}> SUPPORT_EMAIL has been left empty in $ENV_FILE.${NC}\n"
else
printf "${GREEN}> SUPPORT_EMAIL has been set to '${support_email}' in $ENV_FILE.${NC}\n"
fi
else
support_email=$(grep "^SUPPORT_EMAIL=" "$ENV_FILE" | cut -d '=' -f2)
if [ -z "$support_email" ]; then
printf "${GREEN}> SUPPORT_EMAIL already exists in $ENV_FILE but is empty.${NC}\n"
else
printf "${GREEN}> SUPPORT_EMAIL already exists in $ENV_FILE with value: ${support_email}${NC}\n"
fi
fi
}
# Function to build and run the Docker Compose stack with muted output unless an error occurs, showing progress indication
build_and_run_docker_compose() {
printf "${CYAN}> Building Docker Compose stack..."
@@ -340,6 +364,7 @@ main() {
populate_data_protection_cert_pass || exit $?
set_private_email_domains || exit $?
set_smtp_tls_enabled || exit $?
set_support_email || exit $?
generate_admin_password || exit $?
printf "\n${YELLOW}+++ Building Docker containers +++${NC}\n"
printf "\n"

View File

@@ -1,6 +1,7 @@
@page "/user/forgot-password"
@attribute [AllowAnonymous]
@layout Auth.Layout.MainLayout
@inject Config Config
<h2 class="text-2xl font-bold text-gray-900 dark:text-white mb-2">
Lost password
@@ -14,7 +15,14 @@
</p>
<div>
<h3 class="font-medium mb-2 text-gray-900 dark:text-white">Recently changed password</h3>
If you've recently changed your password and are experiencing difficulties signing in with your new password, please note that the server administrator may be able to recover an earlier backup of your vault to assist you.
If this is the case, please contact the server administrator.
@if (!string.IsNullOrEmpty(Config.SupportEmail))
{
<p>If you've recently changed your password and are experiencing difficulties signing in, please contact support at <a href="mailto:@Config.SupportEmail" class="text-blue-600 hover:underline">@Config.SupportEmail</a> for assistance.</p>
}
else
{
<p>If you've recently changed your password and are experiencing difficulties signing in with your new password, please note that the server administrator may be able to recover an earlier backup of your vault to assist you.
If this is the case, please contact the server administrator.</p>
}
</div>
</div>

View File

@@ -57,4 +57,9 @@ public class Config
/// For Argon2Id, this includes DegreeOfParallelism, MemorySize, and Iterations.
/// </summary>
public string? CryptographyOverrideSettings { get; set; }
/// <summary>
/// Gets or sets the support email address that users can contact for password recovery.
/// </summary>
public string? SupportEmail { get; set; }
}

View File

@@ -3,6 +3,9 @@ WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
# Add environment variable for opting out of telemetry which fixes
# "error MSB4166: Child node "8" exited prematurely." issues.
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
WORKDIR /src
# Install Python which is required by the WebAssembly tools

View File

@@ -2,10 +2,12 @@
# Set the default API URL for localhost debugging
DEFAULT_API_URL="http://localhost:81"
DEFAULT_PRIVATE_EMAIL_DOMAINS="localmail.tld"
DEFAULT_SUPPORT_EMAIL=""
# Use the provided API_URL environment variable if it exists, otherwise use the default
API_URL=${API_URL:-$DEFAULT_API_URL}
PRIVATE_EMAIL_DOMAINS=${PRIVATE_EMAIL_DOMAINS:-$DEFAULT_PRIVATE_EMAIL_DOMAINS}
SUPPORT_EMAIL=${SUPPORT_EMAIL:-$DEFAULT_SUPPORT_EMAIL}
# Replace the default URL with the actual API URL
sed -i "s|http://localhost:5092|${API_URL}|g" /usr/share/nginx/html/appsettings.json
@@ -19,6 +21,12 @@ json_array=$(echo $PRIVATE_EMAIL_DOMAINS | awk '{split($0,a,","); printf "["; fo
# Use sed to update the PrivateEmailDomains field in appsettings.json
sed -i.bak "s|\"PrivateEmailDomains\": \[.*\]|\"PrivateEmailDomains\": $json_array|" /usr/share/nginx/html/appsettings.json
# Update support email in appsettings.json
if [ ! -z "$SUPPORT_EMAIL" ]; then
sed -i "s|\"SupportEmail\": \".*\"|\"SupportEmail\": \"$SUPPORT_EMAIL\"|g" /usr/share/nginx/html/appsettings.json
else
sed -i "s|\"SupportEmail\": \".*\"|\"SupportEmail\": \"\"|g" /usr/share/nginx/html/appsettings.json
fi
# Start the application
nginx -g "daemon off;"

View File

@@ -1,4 +1,5 @@
{
"ApiUrl": "http://localhost:5092",
"PrivateEmailDomains": ["example.tld"]
"PrivateEmailDomains": ["example.tld"],
"SupportEmail": "support@example.tld"
}