Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. SOCIAL_AUTH_LINKEDIN_OAUTH2_KEY = '7756p783kegdt2'
  2. SOCIAL_AUTH_LINKEDIN_OAUTH2_SECRET = 'irDH1gCxSJKICfhi'
  3. SOCIAL_AUTH_LINKEDIN_OAUTH2_SCOPE = ['r_basicprofile', 'r_emailaddress']
  4. SOCIAL_AUTH_LINKEDIN_OAUTH2_FIELD_SELECTORS = [
  5. 'email-address', 'headline', 'industry']
  6. SOCIAL_AUTH_LINKEDIN_OAUTH2_EXTRA_DATA = [
  7. ('id', 'id'),
  8. ('first-name', 'first_name'),
  9. ('last-name', 'last_name'),
  10. ('email-address', 'email_address'),
  11. ('industry', 'industry'),
  12. ]
  13.  
  14. SOCIAL_AUTH_PIPELINE = (
  15. 'social_core.pipeline.social_auth.social_details',
  16. 'social_core.pipeline.social_auth.social_uid',
  17. 'social_core.pipeline.social_auth.auth_allowed',
  18. 'social_core.pipeline.social_auth.social_user',
  19. 'social_core.pipeline.user.get_username',
  20. 'social_core.pipeline.social_auth.associate_by_email',
  21. 'social_core.pipeline.user.create_user',
  22. 'social_core.pipeline.social_auth.associate_user',
  23. 'social_core.pipeline.social_auth.load_extra_data',
  24. 'social_core.pipeline.user.user_details',
  25. )
  26.  
  27. LOGIN_URL = '/#authenticate'
  28. LOGOUT_URL = '/user/logout'
  29. LOGIN_REDIRECT_URL = '/accounts/'
  30. LOGOUT_REDIRECT_URL = '/'
  31.  
  32. class CaseInsensitiveModelBackend(ModelBackend):
  33. """ Allows Case insensitive Authentication for Username/emails """
  34.  
  35. def authenticate(self, username=None, password=None, **kwargs):
  36. """ confirm validity of username and password"""
  37.  
  38. try:
  39. user = User.objects.get(username__iexact=username)
  40. if user.check_password(password):
  41. return user
  42. except User.DoesNotExist:
  43. return None
  44.  
  45. def get_user(self, user_id):
  46. try:
  47. return User.objects.get(pk=user_id)
  48. except User.DoesNotExist:
  49. return None
  50.  
  51. path(r'accounts/register', views.register, name='register'),
  52. path(
  53. r'accounts/account-activation-sent/', views.account_activation_sent,
  54. name='account_activation_sent'
  55. ),
  56. path(
  57. r'accounts/activate/<uidb64>/<token>/', views.activate,
  58. name='activate'
  59. ),
  60. path(r'purchase/<token>/', views.purchase, name='purchase'),
  61. path(r'<str:username>/deactivate/', views.deactivate, name='deactivate'),
  62. path(r'deactivated/', views.deactivated, name='deactivated'),
  63. path(r'accounts/login/', views.user_login, name='login'),
  64.  
  65. path(r'<str:username>/', views.dashboard, name='dashboard'),
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement