- {% trans "Sign Up" %} + {% trans "Database Authentication" %}
- {% trans "Please sign up to access the Horilla HRMS." %} + {% trans "Authenticate with your password to initialize the Horilla HRMS database." %}
diff --git a/base/views.py b/base/views.py
index a7328738c..4a61b03b5 100644
--- a/base/views.py
+++ b/base/views.py
@@ -200,10 +200,18 @@ def initialize_database_condition():
def initialize_database(request):
if initialize_database_condition():
- return render(
- request,
- "initialize_database/horilla_user.html",
- )
+ if request.method == "POST":
+ password = request._post.get("password")
+ from horilla.horilla_settings import DB_INIT_PASSWORD as db_password
+
+ if db_password == password:
+ return redirect(initialize_database_user)
+ else:
+ messages.warning(
+ request,
+ _("The password you entered is incorrect. Please try again."),
+ )
+ return HttpResponse("")
else:
return redirect("/")
@@ -238,7 +246,7 @@ def initialize_database_user(request):
"initialize_database/horilla_company.html",
{"form": CompanyForm(initial={"hq": True})},
)
- return render(request, "initialize_database/horilla_user.html")
+ return render(request, "initialize_database/horilla_user_signup.html")
@hx_request_required
@@ -5184,6 +5192,7 @@ def audit_tag_update(request, tag_id):
@login_required
+@permission_required("base.view_multipleapprovalcondition")
def multiple_approval_condition(request):
form = MultipleApproveConditionForm()
conditions = MultipleApprovalCondition.objects.all().order_by("department")[::-1]
diff --git a/horilla/horilla_settings.py b/horilla/horilla_settings.py
new file mode 100644
index 000000000..e0f5ed0c7
--- /dev/null
+++ b/horilla/horilla_settings.py
@@ -0,0 +1,9 @@
+from horilla import settings
+
+"""
+DB_INIT_PASSWORD: str
+
+The password used for database setup and initialization. This password is a
+48-character alphanumeric string generated using a UUID to ensure high entropy and security.
+"""
+DB_INIT_PASSWORD = "d3f6a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d"
\ No newline at end of file
diff --git a/templates/initialize_database/horilla_department_form.html b/templates/initialize_database/horilla_department_form.html
index 47fbcc732..fafd3d741 100644
--- a/templates/initialize_database/horilla_department_form.html
+++ b/templates/initialize_database/horilla_department_form.html
@@ -78,7 +78,7 @@
hx-swap="innerHTML"
class="oh-btn oh-btn--secondary-outline m-2"
role="button"
- >
+ >
{% trans "Next Step" %}
- {% trans "Please sign up to access the Horilla HRMS." %} + {% trans "Authenticate with your password to initialize the Horilla HRMS database." %}