Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 1 addition & 28 deletions website/views/company.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,6 @@
logger = logging.getLogger("slack_bolt")
logger.setLevel(logging.WARNING)

restricted_domain = [
"gmail.com",
"hotmail.com",
"outlook.com",
"yahoo.com",
"proton.com",
]


def get_email_domain(email):
domain = email.split("@")[-1]
return domain


def validate_organization_user(func):
def wrapper(self, request, id, *args, **kwargs):
Expand Down Expand Up @@ -95,15 +82,9 @@ def Organization_view(request, *args, **kwargs):
return redirect("/")

if isinstance(user, AnonymousUser):
messages.error(request, "Login with organization or domain-provided email.")
messages.error(request, "Please login to access your organization.")
return redirect("/accounts/login/")

domain = get_email_domain(user.email)

if domain in restricted_domain:
messages.error(request, "Login with organization or domain provided email.")
return redirect("/")

user_organizations = Organization.objects.filter(Q(admin=user) | Q(managers=user))
if not user_organizations.exists():
# Check if the user is a manager of any domain
Expand Down Expand Up @@ -137,17 +118,9 @@ def post(self, request, *args, **kwargs):
messages.error(request, "Login to create organization")
return redirect("/accounts/login/")

user_domain = get_email_domain(user.email)
organization_name = data.get("organization_name", "")
organization_url = data.get("organization_url", "")

if user_domain in restricted_domain:
messages.error(
request,
"Login with organization email in order to create the organization.",
)
return redirect("/")

if organization_name == "" or Organization.objects.filter(name=organization_name).exists():
messages.error(request, "organization name is invalid or already exists.")
return redirect("register_organization")
Expand Down