diff --git a/infrastructure/templates/infrastructure/html/create.html b/infrastructure/templates/infrastructure/html/create.html
new file mode 100644
index 0000000..d392cf5
--- /dev/null
+++ b/infrastructure/templates/infrastructure/html/create.html
@@ -0,0 +1,11 @@
+{% extends 'dash/common/base.html' %} {% block dash %}
+
{{ title }}
+
+Gitea Admin Credentials
+
+
+ - Username: root
+ - Password: {{ gitea_password }}
+
+
+{% endblock %}
diff --git a/infrastructure/utils.py b/infrastructure/utils.py
index bbb9f0a..049b2cf 100644
--- a/infrastructure/utils.py
+++ b/infrastructure/utils.py
@@ -37,7 +37,7 @@ def create_vm_if_not_exists(instance: Instance) -> (str, Commit):
(gitea_password, commit) = infra.add_vm(instance=instance)
instance = InstanceCreated.objects.create(instance=instance, created=True)
instance.save()
- return gitea_password
+ return (gitea_password, commit)
else:
if str.strip(infra.get_flavor(instance=instance)) != str.strip(
infra.translate_size(instance=instance)
diff --git a/infrastructure/views.py b/infrastructure/views.py
index aaeb7f7..ce5c03d 100644
--- a/infrastructure/views.py
+++ b/infrastructure/views.py
@@ -19,6 +19,7 @@ from django.contrib.auth import get_user_model
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_protect
+from django.core.mail import send_mail
from django.urls import reverse
from accounts.decorators import confirm_access
@@ -48,8 +49,30 @@ def create_instance(request, instance_name: str):
if not payment_fullfilled(instance=instance):
return redirect(reverse("billing.invoice.generate", args=(instance_name,)))
- (gitea_password, commit) = create_vm_if_not_exists(instance=instance)
+ res = create_vm_if_not_exists(instance=instance)
+ if res is not None:
+ (gitea_password, commit) = res
+ send_mail(
+ subject="[Hostea] Gitea admin credentials",
+ message=f"""
+Congratulations on your new Gitea instance!\n
+You can use the following credentials to log into an admin account on
+your new Gitea instance. Great powers come with great responsibilities,
+so use the admin credentials wisely. When in doubt, consult the Gitea
+docs or contact support!\n
+
+ -username : root
+ - password: {gitea_password}
+""",
+ from_email="No reply Hostea", # TODO read from settings.py
+ recipient_list=[request.user.email],
+ )
+
+ ctx = {
+ "gitea_password": gitea_password,
+ }
+ return render(request, "infrastructure/html/create.html", ctx)
return HttpResponse()