Skip to content

Commit

Permalink
Updated Readme.md and fixed settings avatar issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Shritesh99 committed Nov 26, 2023
1 parent a5e5ce5 commit 7eee521
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,20 @@ Django Social Auth for Strawberry Graphql engine.
* [x] Profile pic's URL storage in User's model
* [ ] Relay Support (Coming Soon...)

### Full schema features
#### Usage:
### Installation:
```python
pip install strawberry-django-social-auth
```
- Add this for Avatar support in `settings.py`
```python

SOCIAL_AUTH_PIPELINE = [
...
'gql_social_auth.pipeline.get_avatar', # Get Avatar Pipeline
]
```

### Usage:
1. Use built-In Mutation
```python
@strawberry.type
Expand Down
4 changes: 3 additions & 1 deletion gql_social_auth/types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import strawberry
from typing import TYPE_CHECKING, Optional, cast, NewType
from django.conf import settings

from gqlauth.user.types_ import UserType
from gqlauth.core.utils import app_settings
Expand Down Expand Up @@ -55,9 +56,10 @@ def from_social_user(cls, user) -> "SocialType":
user=cast(UserType, user),
token=TokenType.from_user(user),
uid=user.social_user.uid,
avatar=user.avatar,
provider=user.social_user.provider,
)
if hasattr(settings, 'SOCIAL_AUTH_PIPELINE') and 'gql_social_auth.pipeline.get_avatar' in settings.SOCIAL_AUTH_PIPELINE:
ret.avatar = user.avatar
if app_settings.JWT_LONG_RUNNING_REFRESH_TOKEN:
ret.refresh_token = cast(RefreshTokenType, RefreshToken.from_user(user))
return ret
7 changes: 1 addition & 6 deletions testproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
BASE_DIR = Path(__file__).parent
sys.path.append(str(BASE_DIR / "testproject"))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/

Expand Down Expand Up @@ -92,7 +91,6 @@
}
}


# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators

Expand Down Expand Up @@ -151,8 +149,6 @@

# Update the user record with any changed info from the auth service.
'social_core.pipeline.user.user_details',

'gql_social_auth.pipeline.get_avatar',
]

# Internationalization
Expand All @@ -166,7 +162,6 @@

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/

Expand All @@ -189,4 +184,4 @@
REGISTER_REQUIRE_CAPTCHA=True,
CAPTCHA_SAVE_IMAGE=True,
SEND_ACTIVATION_EMAIL=False,
)
)

0 comments on commit 7eee521

Please sign in to comment.