Skip to content

Commit

Permalink
Merge pull request #10 from CheesecakeLabs/bernardo/refactor-social-v…
Browse files Browse the repository at this point in the history
…iews

Create Auth view base and adapt social endpoints
  • Loading branch information
smaniotto authored Apr 17, 2018
2 parents 133c8e1 + 9f75133 commit 568c90c
Show file tree
Hide file tree
Showing 3 changed files with 219 additions and 210 deletions.
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Response (depends on REGISTER_FIELDS and USER_SERIALIZER) - 200 OK
}
}
```
**Note:** the user payload may vary according to specified REGISTER_FIELDS and USER_SERIALIZER.

`POST /api/v1/register`
Body (depends on REGISTER_FIELDS and USER_SERIALIZER -- always has a password)
Expand All @@ -84,12 +85,12 @@ Response (depends on REGISTER_FIELDS and USER_SERIALIZER) - 201 CREATED
"user": {
"id": 1,
"email": "[email protected]",
"password": "secret",
"first_name": "Example",
"last_name": "Example"
}
}
```
**Note:** the user payload may vary according to specified REGISTER_FIELDS and USER_SERIALIZER.

`POST /api/v1/password-reset/`
Body
Expand All @@ -109,7 +110,33 @@ Note: it always returns success, even if the provided email is not registered.

## Social Endpoints

TODO
`GET /api/v1/social/google`
`GET /api/v1/social/facebook`
**Note:** this should not be XHR request, the user will be redirected to consent screen. After
consent, the user is redirected to platform REDIRECT_URI added on settings, where a code is
extracted from the URL hash.

`POST /api/v1/social/google`
`POST /api/v1/social/facebook`
Body
```
{
"code": "<code from previous step>"
}
```
Response - 200 OK
```
{
"token": "supersecret",
"user": {
"id": 1,
"email": "[email protected]",
"first_name": "Example",
"last_name": "Example"
}
}
```
**Note:** the user payload may vary according to specified REGISTER_FIELDS and USER_SERIALIZER.

## Contributing

Expand Down
8 changes: 4 additions & 4 deletions cklauth/api/v1/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from . import views

urlpatterns = [
path('register', views.register, name='register'),
path('login', views.login, name='login'),
path('register', views.RegisterView.as_view(), name='register'),
path('login', views.LoginView.as_view(), name='login'),
path('social/google', views.GoogleAuthView.as_view(), name='google'),
path('social/facebook', views.FacebookAuthView.as_view(), name='facebook'),
path('password-reset', views.password_reset, name='password-reset'),
path('google', views.GoogleAuthView.as_view(), name='google'),
path('facebook', views.FacebookAuthView.as_view(), name='facebook'),
]
Loading

0 comments on commit 568c90c

Please sign in to comment.