mirror of
https://github.com/Tivix/django-rest-auth.git
synced 2025-02-11 23:40:36 +03:00
Add docker setup for demo project
This commit is contained in:
parent
3e8a7e308c
commit
18983960a1
8
demo/Dockerfile
Normal file
8
demo/Dockerfile
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
FROM python:3
|
||||||
|
ENV PYTHONUNBUFFERED 1
|
||||||
|
RUN mkdir /code
|
||||||
|
WORKDIR /code
|
||||||
|
COPY requirements.txt /code/
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
COPY . /code/
|
||||||
|
|
|
@ -150,6 +150,6 @@ CACHES = {
|
||||||
}
|
}
|
||||||
|
|
||||||
REST_AUTH_SERIALIZERS = {
|
REST_AUTH_SERIALIZERS = {
|
||||||
'LOGIN_SERIALIZER': 'myapp.serializers.RestAuthLoginSerializer',
|
'LOGIN_SERIALIZER': 'myapp.serializers.RestAuthAxesLoginSerializer',
|
||||||
# 'TOKEN_SERIALIZER': 'path.to.custom.TokenSerializer',
|
# 'TOKEN_SERIALIZER': 'path.to.custom.TokenSerializer',
|
||||||
}
|
}
|
||||||
|
|
13
demo/docker-compose.yml
Normal file
13
demo/docker-compose.yml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
build: .
|
||||||
|
image: gableroux/django-rest-auth-demo
|
||||||
|
command: python manage.py runserver 0.0.0.0:1234
|
||||||
|
environment:
|
||||||
|
PYTHONUNBUFFERED: 1
|
||||||
|
volumes:
|
||||||
|
- .:/code
|
||||||
|
ports:
|
||||||
|
- "1234:1234"
|
|
@ -5,12 +5,12 @@ from rest_framework import exceptions
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyAbstractClass
|
# noinspection PyAbstractClass
|
||||||
class RestAuthLoginSerializer(LoginSerializer):
|
class RestAuthAxesLoginSerializer(LoginSerializer):
|
||||||
|
|
||||||
def validate(self, attrs):
|
def validate(self, attrs):
|
||||||
try:
|
try:
|
||||||
attrs = super().validate(attrs)
|
return super().validate(attrs)
|
||||||
except exceptions.ValidationError:
|
except exceptions.ValidationError as e:
|
||||||
if getattr(self.context['request'], 'axes_locked_out', None):
|
if getattr(self.context['request'], 'axes_locked_out', None):
|
||||||
raise serializers.ValidationError(get_lockout_message())
|
raise serializers.ValidationError(get_lockout_message())
|
||||||
return attrs
|
raise e
|
||||||
|
|
Loading…
Reference in New Issue
Block a user