示例#1
0
# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
urlpatterns = [
    url(r'^', include(router.urls)),
    url(r'^api-auth/',
        include('rest_framework.urls', namespace='rest_framework')),
    url(r'^rest-auth/registration/', include('rest_auth.registration.urls')),
    url(r'^rest-auth/facebook/$',
        views.FacebookLogin.as_view(),
        name='fb_login'),
    url(r'^rest-auth/twitter/$',
        views.TwitterLogin.as_view(),
        name='twitter_login'),
    url(r'^rest-auth/facebook/connect/$',
        views.FacebookConnect.as_view(),
        name='fb_connect'),
    url(r'^rest-auth/twitter/connect/$',
        views.TwitterConnect.as_view(),
        name='twitter_connect'),
    url(r'^rest-auth/', include('rest_auth.urls')),
    url(r'^api-token-auth/', obtain_jwt_token),
    url(r'^api-token-refresh/', refresh_jwt_token),
    url(r'^api-token-verify/', verify_jwt_token),
    url(r'^socialaccounts/$',
        SocialAccountListView.as_view(),
        name='social_account_list'),
    url(r'^socialaccounts/(?P<pk>\d+)/disconnect/$',
        SocialAccountDisconnectView.as_view(),
        name='social_account_disconnect')
]
示例#2
0
from django.urls import include, path
from rest_auth.registration.views import SocialAccountListView

from .views import GoogleConnectView, GoogleLoginView

urlpatterns = [
    path("", include("rest_auth.urls")),
    path(
        "accounts/",
        include("allauth.socialaccount.urls"),
        name="socialaccount_signup",
    ),
    path("socialaccounts/", SocialAccountListView.as_view()),
    path(
        "google/",
        include([
            path("login/", GoogleLoginView.as_view()),
            path("connect/", GoogleConnectView.as_view()),
        ]),
    ),
]
示例#3
0
文件: auth.py 项目: yutaoxu/rssant
        Note that if you have architected your system such that email
        confirmations are sent outside of the request context `request`
        can be `None` here.
        """
        url = 'account-confirm-email/{}'.format(emailconfirmation.key)
        return urljoin(CONFIG.root_url, url)

    def send_confirmation_mail(self, request, emailconfirmation, signup):
        username = emailconfirmation.email_address.user.username
        link = self.get_email_confirmation_url(request, emailconfirmation)
        ctx = {
            "link": link,
            "username": username,
            "user": emailconfirmation.email_address.user,
            "key": emailconfirmation.key,
        }
        sender = self.get_from_email()
        receiver = emailconfirmation.email_address.email
        EMAIL_CONFIRM_TEMPLATE.send(sender, receiver, ctx)


urlpaterns = [
    path('auth/', include('rest_auth.urls')),
    path('auth/registration/', include('rest_auth.registration.urls')),
    path('auth/github/', GitHubLogin.as_view()),
    path('auth/github/connect/', GitHubConnect.as_view()),
    path('auth/socialaccount/', SocialAccountListView.as_view()),
    path('auth/socialaccount/<int:pk>/disconnect/', SocialAccountDisconnectView.as_view())
]
示例#4
0
from django.conf import settings
from django.urls import include, path
from django.views.generic import TemplateView
from rest_auth.registration.views import SocialAccountListView
from rest_framework_jwt.views import refresh_jwt_token, verify_jwt_token

from . import views

urlpatterns = [
    path("", include("django.contrib.auth.urls")),
    path("auth/social/google", views.GoogleLogin.as_view(), name="google_rest_login"),
    path("auth/social/facebook", views.GoogleLogin.as_view(), name="fb_rest_login"),
    path("auth/social/github", views.GithubLogin.as_view(), name="gh_rest_login"),
    path("auth/social/list", SocialAccountListView.as_view(), name="social_list"),
    path("auth/", include("rest_auth.urls")),
    path("auth/token/refresh", refresh_jwt_token, name="refresh_jwt"),
    path("auth/token/verify", verify_jwt_token, name="verify_jwt"),
    path("auth/registration/", include("rest_auth.registration.urls")),
    path("auth/profile", views.UpdateProfile.as_view(), name="update_profile"),
    # Used by allauth to send the "verification email sent" response to client
    path(
        "auth/account-email-verification-sent",
        TemplateView.as_view(),
        name="account_email_verification_sent",
    ),
]

# Used for social auth development
if settings.DEBUG or settings.TESTING:
    urlpatterns += [
        path("dev/", include("allauth.account.urls")),
示例#5
0
from django.urls import path, include
from rest_auth.registration.views import SocialAccountListView, SocialAccountDisconnectView

from apps.users.api import views

app_name = 'api_users'

urlpatterns = [
    path('', include('rest_auth.urls')),
    path('register/', include('rest_auth.registration.urls')),
    path('facebook/', views.FacebookLogin.as_view()),
    path('twitter/', views.TwitterLogin.as_view()),
    path('github/', views.GithubLogin.as_view()),
    path('facebook/connect/', views.FacebookConnect.as_view()),
    path('twitter/connect/', views.TwitterConnect.as_view()),
    path('github/connect/', views.GithubConnect.as_view()),
    path('connected/', SocialAccountListView.as_view()),
    path('connected/<int:pk>/disconnect/',
         SocialAccountDisconnectView.as_view())
]
示例#6
0
    url('^admin/', admin.site.urls),
    url(r'^auth/', include('rest_auth.urls')),
    url(r'^auth/registration/', include('rest_auth.registration.urls')),
    re_path(r'^auth/registration/account-confirm-email/', VerifyEmailView.as_view(),
            name='account_email_verification_sent'),
    url(r'^password/reset/$', PasswordResetView.as_view(),
        name='rest_password_reset'),
    re_path(
        r'^rest-auth/password/reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
        PasswordResetConfirmView.as_view(), name='password_reset_confirm'),
    # re_path(r'^auth/registration/account-confirm-email/(?P<key>[-:\w]+)/$', VerifyEmailView.as_view(), name='account_confirm_email'),
    url(r'^auth/facebook/$', FacebookLogin.as_view(), name='fb_login'),
    url(r'^auth/twitter/$', TwitterLogin.as_view(), name='twitter_login'),
    url(r'^auth/facebook/connect/$', FacebookConnect.as_view(), name='fb_connect'),
    url(r'^auth/twitter/connect/$', TwitterConnect.as_view(), name='twitter_connect'),
    url(r'^social-accounts/$', SocialAccountListView.as_view(), name='social_account_list'),
    url(r'^social-accounts/(?P<pk>\d+)/disconnect/$', SocialAccountDisconnectView.as_view(),
        name='social_account_disconnect'),
    url(r'^api-token-verify/', verify_jwt_token),
    url(r'^api-token-refresh/', refresh_jwt_token),
    url(r'^api-token-auth/', obtain_jwt_token),

    path('email/<email>/change', EmailHandlerAPI.as_view({'post': 'change_email'}), name='change_email'),
    path('email/<email>/primary', EmailHandlerAPI.as_view({'post': 'make_email_primary'}), name='make_email_primary'),
    path('email/<email>/verify', EmailHandlerAPI.as_view({'post': 'send_confirmation'}), name='send_confirmation'),
    path('email/new', EmailHandlerAPI.as_view({'post': 'add_email'}), name='add_email'),

    # serve media
    url(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT, }, name='media'),
    url(r'^api/search/', include(search_index_urls)),
from django.urls import include, path
from rest_auth.registration.views import SocialAccountListView, SocialAccountDisconnectView

from swissrugbystats.api.auth import views

urlpatterns = [
    path('rest-auth/', include('rest_auth.urls')),
    path('accounts/', include('allauth.urls')),

    path('rest-auth/facebook', views.FacebookLogin.as_view(), name='fb_login'),
    path('rest-auth/twitter', views.TwitterLogin.as_view(), name='twitter_login'),

    # connect social media accounts
    path('rest-auth/facebook/connect', views.FacebookConnect.as_view(), name='fb_connect'),
    path('rest-auth/twitter/connect', views.TwitterConnect.as_view(), name='twitter_connect'),

    # list views of linked accounts
    path('socialaccounts', SocialAccountListView.as_view(), name='social_account_list'),
    path('socialaccounts/<int:pk>/disconnect', SocialAccountDisconnectView.as_view(),
         name='social_account_disconnect'),

    # JWT Authentication - currently disabled
    # re_path(r'^api-token-auth/?', obtain_jwt_token),
    # re_path(r'^api-token-refresh/?', refresh_jwt_token),

]
示例#8
0
def twitter_login_view(request):
    serializer = TwitterLoginSerializerFoo(
        data={'access_token': '11223344', 'token_secret': '55667788'},
        context={'request': request}
    )
    serializer.is_valid(raise_exception=True)


class TwitterLoginNoAdapter(SocialLoginView):
    serializer_class = TwitterLoginSerializer


urlpatterns += [
    url(r'^rest-registration/', include('rest_auth.registration.urls')),
    url(r'^test-admin/', include(django_urls)),
    url(r'^account-email-verification-sent/$', TemplateView.as_view(),
        name='account_email_verification_sent'),
    url(r'^account-confirm-email/(?P<key>[-:\w]+)/$', TemplateView.as_view(),
        name='account_confirm_email'),
    url(r'^social-login/facebook/$', FacebookLogin.as_view(), name='fb_login'),
    url(r'^social-login/twitter/$', TwitterLogin.as_view(), name='tw_login'),
    url(r'^social-login/twitter-no-view/$', twitter_login_view, name='tw_login_no_view'),
    url(r'^social-login/twitter-no-adapter/$', TwitterLoginNoAdapter.as_view(), name='tw_login_no_adapter'),
    url(r'^social-login/facebook/connect/$', FacebookConnect.as_view(), name='fb_connect'),
    url(r'^social-login/twitter/connect/$', TwitterConnect.as_view(), name='tw_connect'),
    url(r'^socialaccounts/$', SocialAccountListView.as_view(), name='social_account_list'),
    url(r'^socialaccounts/(?P<pk>\d+)/disconnect/$', SocialAccountDisconnectView.as_view(),
        name='social_account_disconnect'),
    url(r'^accounts/', include('allauth.socialaccount.urls'))
]