2017-07-25 18:31:42 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from django.conf.urls import include, url
|
2017-12-29 18:19:01 +01:00
|
|
|
from django.utils.module_loading import import_string
|
2017-07-25 18:31:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
def default_urlpatterns(provider):
|
|
|
|
package = provider.get_package()
|
|
|
|
|
2017-12-29 18:19:01 +01:00
|
|
|
try:
|
|
|
|
login_view = import_string(package + '.views.login')
|
|
|
|
except ImportError:
|
|
|
|
raise ImportError(
|
|
|
|
"The login view for the '{id}' provider is lacking from the "
|
|
|
|
"'views' module of its app.\n"
|
|
|
|
"You may want to add:\n"
|
|
|
|
"from allauth_cas.views import CASLoginView\n\n"
|
|
|
|
"login = CASLoginView.adapter_view(<LocalCASAdapter>)"
|
|
|
|
.format(id=provider.id)
|
|
|
|
)
|
|
|
|
|
|
|
|
try:
|
|
|
|
callback_view = import_string(package + '.views.callback')
|
|
|
|
except ImportError:
|
|
|
|
raise ImportError(
|
|
|
|
"The callback view for the '{id}' provider is lacking from the "
|
|
|
|
"'views' module of its app.\n"
|
|
|
|
"You may want to add:\n"
|
|
|
|
"from allauth_cas.views import CASCallbackView\n\n"
|
|
|
|
"callback = CASCallbackView.adapter_view(<LocalCASAdapter>)"
|
|
|
|
.format(id=provider.id)
|
|
|
|
)
|
|
|
|
|
|
|
|
try:
|
|
|
|
logout_view = import_string(package + '.views.logout')
|
|
|
|
except ImportError:
|
|
|
|
logout_view = None
|
2017-07-25 18:31:42 +02:00
|
|
|
|
|
|
|
urlpatterns = [
|
2017-12-29 18:19:01 +01:00
|
|
|
url('^login/$', login_view,
|
|
|
|
name=provider.id + '_login'),
|
|
|
|
url('^login/callback/$', callback_view,
|
|
|
|
name=provider.id + '_callback'),
|
2017-07-25 18:31:42 +02:00
|
|
|
]
|
|
|
|
|
2017-12-29 18:19:01 +01:00
|
|
|
if logout_view is not None:
|
|
|
|
urlpatterns += [
|
|
|
|
url('^logout/$', logout_view,
|
|
|
|
name=provider.id + '_logout'),
|
|
|
|
]
|
|
|
|
|
2017-07-25 18:31:42 +02:00
|
|
|
return [url('^' + provider.get_slug() + '/', include(urlpatterns))]
|