Commit be77c2e3 authored by Alexander Færøy's avatar Alexander Færøy 🍍
Browse files

Add automatic approval of some email providers. For now: riseup.net.

parent 0b9dcc34
......@@ -2,13 +2,26 @@ from django.shortcuts import render
from django.http import HttpResponseRedirect
from .models import GitlabAccountRequestForm
from .gitlab import approve_user
from lobby.settings import AUTO_ACCEPT_LIST
def index(request):
if request.method == "POST":
form = GitlabAccountRequestForm(request.POST)
if form.is_valid():
form.save()
model = form.save()
# Auto-accept some accounts (if the username is free).
email = model.email
for hostname in AUTO_ACCEPT_LIST:
email = email.lower()
if email.endswith("@" + hostname):
approve_user(model)
return HttpResponseRedirect('/success/')
return HttpResponseRedirect('/failure/')
......
......@@ -105,3 +105,6 @@ SECRET_KEY = ""
# SECURITY WARNING: Gitlab credentials.
GITLAB_URL = "https://gitlab.torproject.org/"
GITLAB_SECRET_TOKEN = ""
# SECURITY: List of suffixes to automatic approve for email accounts.
AUTO_ACCEPT_LIST = ["riseup.net"]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment