-
-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from WongSaang/rest-auth
Support for the official ChatGPT model: gpt-3.5-turbo
- Loading branch information
Showing
15 changed files
with
217 additions
and
92 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
Empty file.
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,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
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 allauth.account.adapter import DefaultAccountAdapter | ||
from allauth.utils import build_absolute_uri | ||
|
||
class AccountAdapter(DefaultAccountAdapter): | ||
|
||
def get_email_confirmation_url(self, request, emailconfirmation): | ||
location = '/account/verify-email/{}'.format(emailconfirmation.key) | ||
return build_absolute_uri(None, location) |
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,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class AccountConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'account' |
Empty file.
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,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
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,40 @@ | ||
from django.conf import settings | ||
from django.contrib.auth import authenticate, get_user_model | ||
from rest_framework import exceptions, serializers | ||
|
||
# Get the UserModel | ||
UserModel = get_user_model() | ||
|
||
class UserDetailsSerializer(serializers.ModelSerializer): | ||
""" | ||
User model w/o password | ||
""" | ||
|
||
@staticmethod | ||
def validate_username(username): | ||
if 'allauth.account' not in settings.INSTALLED_APPS: | ||
# We don't need to call the all-auth | ||
# username validator unless its installed | ||
return username | ||
|
||
from allauth.account.adapter import get_adapter | ||
username = get_adapter().clean_username(username) | ||
return username | ||
|
||
class Meta: | ||
extra_fields = [] | ||
# see https://github.com/iMerica/dj-rest-auth/issues/181 | ||
# UserModel.XYZ causing attribute error while importing other | ||
# classes from `serializers.py`. So, we need to check whether the auth model has | ||
# the attribute or not | ||
if hasattr(UserModel, 'USERNAME_FIELD'): | ||
extra_fields.append(UserModel.USERNAME_FIELD) | ||
if hasattr(UserModel, 'EMAIL_FIELD'): | ||
extra_fields.append(UserModel.EMAIL_FIELD) | ||
if hasattr(UserModel, 'first_name'): | ||
extra_fields.append('first_name') | ||
if hasattr(UserModel, 'last_name'): | ||
extra_fields.append('last_name') | ||
model = UserModel | ||
fields = (*extra_fields,) | ||
read_only_fields = ('email',) |
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,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
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,4 @@ | ||
from django.shortcuts import render | ||
|
||
# Create your views here. | ||
from dj_rest_auth.views import LoginView |
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
Oops, something went wrong.