perf: passkey 只允许本地用户开启

pull/11808/head
ibuler 2023-10-11 17:48:58 +08:00 committed by Bryan
parent 7cd2736e82
commit 38aa828eb8
2 changed files with 5 additions and 0 deletions

View File

@ -22,6 +22,8 @@ class PasskeyViewSet(AuthMixin, FlashMessageMixin, ModelViewSet):
@action(methods=['get', 'post'], detail=False, url_path='register')
def register(self, request):
if request.user.source != 'local':
return JsonResponse({'error': _('Only register passkey for local user')}, status=400)
if request.method == 'GET':
register_data, state = register_begin(request)
return JsonResponse(dict(register_data))

View File

@ -7,3 +7,6 @@ class PasskeyAuthBackend(JMSModelBackend):
@staticmethod
def is_enabled():
return settings.AUTH_PASSKEY
def user_can_authenticate(self, user):
return user.source == 'local'