You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@senssoft.apache.org by ar...@apache.org on 2016/10/21 16:12:03 UTC

[10/48] incubator-senssoft-tap git commit: Login returns token

Login returns token


Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-tap/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-tap/commit/edda1836
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-tap/tree/edda1836
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-tap/diff/edda1836

Branch: refs/heads/master
Commit: edda18361c51d7ddb9634018e141b2a6ec64947c
Parents: 8c116e7
Author: Arthi Vezhavendan <ar...@gmail.com>
Authored: Fri Jul 22 11:17:27 2016 -0400
Committer: Arthi Vezhavendan <ar...@gmail.com>
Committed: Fri Jul 22 11:17:27 2016 -0400

----------------------------------------------------------------------
 app_mgr/urls.py  |  3 +++
 app_mgr/views.py | 14 ++++++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-senssoft-tap/blob/edda1836/app_mgr/urls.py
----------------------------------------------------------------------
diff --git a/app_mgr/urls.py b/app_mgr/urls.py
index 28dd27e..9c5392a 100644
--- a/app_mgr/urls.py
+++ b/app_mgr/urls.py
@@ -36,4 +36,7 @@ urlpatterns = [
     url(r'^user/(?P<pk>current)/$', views.UserProfileInstanceView.as_view(), name='user-current'),
     url(r'^org/(?P<pk>[\d]+)/$', views.OrganizationInstanceView.as_view(), name='org-instance'),
     url(r'^app/(?P<pk>[\d]+)/$', views.ApplicationInstanceView.as_view(), name='app-instance'),
+
+    #url(r'^appresults/(?P<pk>[\d]+)/$', views.UserProfileInstanceView.as_view(), name='user-instance'),
+    
 ]

http://git-wip-us.apache.org/repos/asf/incubator-senssoft-tap/blob/edda1836/app_mgr/views.py
----------------------------------------------------------------------
diff --git a/app_mgr/views.py b/app_mgr/views.py
index 3dbbec0..7100e8c 100644
--- a/app_mgr/views.py
+++ b/app_mgr/views.py
@@ -8,6 +8,7 @@ from django.core.urlresolvers import reverse
 from django.template import RequestContext
 from django.conf import settings
 
+
 from django.db import IntegrityError
 from django.db.models import Q
 
@@ -19,6 +20,7 @@ from rest_framework import generics
 from rest_framework.authentication import TokenAuthentication
 from rest_framework.permissions import IsAuthenticated
 from rest_framework.response import Response
+#from rest_framework.authtoken import views as token_views
 
 from guardian.shortcuts import assign_perm, get_objects_for_user
 
@@ -28,6 +30,7 @@ from app_mgr.models import UserProfile, Organization, Application, AppVersion
 from app_mgr.serializers import UserProfileSerializer, OrganizationSerializer, ApplicationSerializer
 
 import datetime
+import requests 
 
 #
 # RESTFUL VIEWS
@@ -255,11 +258,9 @@ def login_user(request):
                 # If the account is valid and active, we can log the user in.
                 # We'll send the user back to the homepage.
                 login(request, user)
-                userToken = "HttpRequest"
+                userToken = get_token(email, password)
                 print( "Successful Login: {0}, id: {1}, token: {2}".format(email, user.id, userToken) )
-                #return HttpResponseRedirect('/app_mgr/user_profile/')
-                return HttpResponse("Successful Login: {0}, id: {1}, token: {2}".format(email, user.id, userToken))
-                #return HttpResponseRedirect('../../api-token-auth/')
+                return HttpResponse(userToken)
             else:
                 # An inactive account was used - no logging in!
                 return HttpResponse("Your TAP account is disabled.")
@@ -279,6 +280,11 @@ def login_user(request):
 
         # return login_view(request, authentication_form=MyAuthForm)
 
+def get_token(email, password):
+    credentials = {'username':email, 'password':password}
+    tokenResponse = requests.post('http://localhost:8000/api-token-auth/', credentials)
+    return tokenResponse.text
+
 def reset_confirm(request, uidb64=None, token=None):
     return password_reset_confirm(request, template_name='registration/reset_password_confirm.html',
                                   uidb64=uidb64, token=token,