3
3
from social .apps .django_app .default .models import UserSocialAuth
4
4
from linkedin import linkedin
5
5
#from django.http import HttpResponse
6
-
6
+ from django . core . exceptions import PermissionDenied
7
7
8
8
def logout (request ):
9
9
"""logs the user out, then redirects to the home page"""
@@ -14,7 +14,6 @@ def home(request):
14
14
"""displays the home page"""
15
15
return render (request , 'home.html' , {})
16
16
17
-
18
17
def about (request ):
19
18
"""displays the about page"""
20
19
return render (request , 'about.html' , {})
@@ -23,7 +22,6 @@ def contact(request):
23
22
"""displays the contact page"""
24
23
return render (request , 'contact.html' , {})
25
24
26
-
27
25
def temp (request ):
28
26
"""this is used for the popup window which houses the linkedin login page"""
29
27
return render (request , 'temp.html' , {})
@@ -59,9 +57,13 @@ def get_access_tokens(user):
59
57
def news (request ):
60
58
"""Diplays the LinkedIn content, this is the critical view of the app"""
61
59
62
- if not request .user .is_authenticated ():
63
- return redirect ('home' )
60
+ # if not request.user.is_authenticated():
61
+ # return redirect('home')
64
62
63
+ # handle unauthorized access with a 403
64
+ if not request .user .is_authenticated () or not request .user .is_active :
65
+ raise PermissionDenied
66
+
65
67
API_KEY = '75l485e9k29snc'
66
68
API_SECRET = 'iw7fONMpJZcY5HOb'
67
69
USER_KEY , USER_SECRET = get_access_tokens (request .user )
@@ -114,4 +116,4 @@ def news(request):
114
116
#raw_input()
115
117
'''
116
118
return render (request , 'news.html' , {'post_list' :group_posts ['values' ], 'update_list' : update_list })
117
-
119
+
0 commit comments