forked from enviPath/enviPy
[Feature] Register / Login / Logout View Testing (#126)
Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#126
This commit is contained in:
@ -2,6 +2,7 @@ import re
|
||||
import logging
|
||||
import json
|
||||
from typing import Union, List, Optional, Set, Dict, Any
|
||||
from uuid import UUID
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db import transaction
|
||||
@ -326,9 +327,9 @@ class PackageManager(object):
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def has_package_permission(user: 'User', package: Union[str, 'Package'], permission: str):
|
||||
def has_package_permission(user: 'User', package: Union[str, UUID, 'Package'], permission: str):
|
||||
|
||||
if isinstance(package, str):
|
||||
if isinstance(package, str) or isinstance(package, UUID):
|
||||
package = Package.objects.get(uuid=package)
|
||||
|
||||
groups = GroupManager.get_groups(user)
|
||||
|
||||
@ -6,6 +6,7 @@ from django.conf import settings as s
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.http import JsonResponse, HttpResponse, HttpResponseNotAllowed, HttpResponseBadRequest
|
||||
from django.shortcuts import render, redirect
|
||||
from django.urls import reverse
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from envipy_additional_information import NAME_MAPPING
|
||||
from oauth2_provider.decorators import protected_resource
|
||||
@ -81,7 +82,7 @@ def login(request):
|
||||
if next := request.POST.get('next'):
|
||||
return redirect(next)
|
||||
|
||||
return redirect(s.SERVER_URL)
|
||||
return redirect(reverse("index"))
|
||||
else:
|
||||
context['message'] = "Login failed!"
|
||||
return render(request, 'static/login.html', context)
|
||||
|
||||
Reference in New Issue
Block a user