-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3888ccb
commit 00cd36a
Showing
9 changed files
with
65 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from .settings import * | ||
from .settings import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
from abstract_auth.abstract_user_profile import AbstractAuthProfile | ||
|
||
|
||
class AuthFirebaseProfile(AbstractAuthProfile): | ||
class UserFirebaseProfile(AbstractAuthProfile): | ||
class Meta: | ||
app_label = "django_firebase_auth" | ||
abstract = False |
Empty file.
15 changes: 15 additions & 0 deletions
15
django_firebase_auth/serializers/firebase_authentication_serializer.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from django.utils.translation import gettext_lazy as _ | ||
from rest_framework import serializers | ||
|
||
|
||
|
||
class FirebaseAuthTokenSerializer(serializers.Serializer): | ||
firebase_auth_token = serializers.CharField() | ||
|
||
def validate(self, attrs): | ||
firebase_auth_token = attrs.get("firebase_auth_token") | ||
if firebase_auth_token is None: | ||
msg = _('Must include "firebase_auth_token".') | ||
raise serializers.ValidationError(msg, code="authorization") | ||
attrs["user"] = self.context["user"] | ||
return attrs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.urls import path | ||
from django_firebase_auth.viewsets.firebase_auth_viewset import FirebaseAuthViewSet | ||
|
||
app_name = 'firebase_auth' | ||
urlpatterns = [ | ||
path('login/', FirebaseAuthViewSet.as_view(), name='login'), | ||
# path('logout/', FirebaseAuthLogoutViewSet.as_view(), name='logout'), | ||
] |
Empty file.
13 changes: 13 additions & 0 deletions
13
django_firebase_auth/viewsets/firebase_auth_logout_viewset.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from rest_framework import viewsets | ||
|
||
|
||
class FirebaseAuthLogoutViewSet(viewsets.ViewSet): | ||
""" | ||
This viewset is used to logout the user from the firebase. | ||
""" | ||
|
||
def create(self, request): | ||
""" | ||
This method is used to logout the user from the firebase. | ||
""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from rest_framework import permissions | ||
from rest_framework.authtoken.views import ObtainAuthToken | ||
|
||
from django_firebase_auth.firebase_auth import FirebaseAuthentication | ||
from django_firebase_auth.serializers.firebase_authentication_serializer import ( | ||
FirebaseAuthTokenSerializer, | ||
) | ||
|
||
|
||
class FirebaseAuthViewSet(ObtainAuthToken): | ||
permission_classes = (permissions.AllowAny,) | ||
authentication_classes = [FirebaseAuthentication] | ||
serializer_class = FirebaseAuthTokenSerializer | ||
|
||
def get_serializer_context(self): | ||
user = self.request.user | ||
return {"user": user} |