Subscriber Portal is fully integrated with XOS
diff --git a/applications/subscriberPortal/bs-config.js b/applications/subscriberPortal/bs-config.js
index f608075..f79f762 100644
--- a/applications/subscriberPortal/bs-config.js
+++ b/applications/subscriberPortal/bs-config.js
@@ -40,6 +40,7 @@
],
"server": {
baseDir: './src',
+ //directory: true,
routes: {
'/rs/dashboard': './mocks/dashboard.json',
'/rs/bundle': './mocks/bundle.json',
diff --git a/applications/subscriberPortal/src/app/fw/services/rest.js b/applications/subscriberPortal/src/app/fw/services/rest.js
index e5ea7e0..e97f091 100644
--- a/applications/subscriberPortal/src/app/fw/services/rest.js
+++ b/applications/subscriberPortal/src/app/fw/services/rest.js
@@ -40,8 +40,11 @@
user = JSON.parse(res.data.user);
return $http.get(cordConfig.url + '/xos/tenantrootprivileges?user=' + user.id);
})
- .then(function(subscriber){
- console.log(subscriber);
+ .then(function(subscribers){
+ // subscribers are an array because the way Django perform query
+ // but one user is related to only one subscriber
+
+ $cookies.put('subscriberId', subscribers.data[0].id);
deferred.resolve(user);
})
.catch(function(e){
diff --git a/applications/subscriberPortal/src/app/view/home/home.js b/applications/subscriberPortal/src/app/view/home/home.js
index bc59efb..c7de985 100644
--- a/applications/subscriberPortal/src/app/view/home/home.js
+++ b/applications/subscriberPortal/src/app/view/home/home.js
@@ -18,12 +18,11 @@
'use strict';
angular.module('cordHome', [])
- .controller('CordHomeCtrl', function ($log, $scope, cordConfig, SubscriberUsers) {
+ .controller('CordHomeCtrl', function ($log, $scope, $cookies, cordConfig, SubscriberUsers) {
$scope.page.curr = 'dashboard';
- // NOTE subscriberId should be retrieved by login
- SubscriberUsers.query({subscriberId: 1}).$promise
+ SubscriberUsers.query({subscriberId: $cookies.get('subscriberId')}).$promise
.then(function(res){
$scope.bundle_name = cordConfig.bundles[cordConfig.activeBundle].name;
$scope.bundle_desc = cordConfig.bundles[cordConfig.activeBundle].desc;
diff --git a/applications/subscriberPortal/src/app/view/user/user.js b/applications/subscriberPortal/src/app/view/user/user.js
index d1ab838..57e0a4c 100644
--- a/applications/subscriberPortal/src/app/view/user/user.js
+++ b/applications/subscriberPortal/src/app/view/user/user.js
@@ -25,9 +25,8 @@
$scope.newLevels = {};
$scope.showCheck = false;
$scope.ratingsShown = false;
-
- // NOTE subscriberId should be retrieved by login
- SubscriberUsers.query({subscriberId: 1}).$promise
+
+ SubscriberUsers.query({subscriberId: $cookies.get('subscriberId')}).$promise
.then(function(res){
$scope.isFamily = cordConfig.bundles[cordConfig.activeBundle].id === 'family';
// if bundle is family search for url_filter level
diff --git a/xos/core/xoslib/methods/loginview.py b/xos/core/xoslib/methods/loginview.py
index 975a65b..69ee289 100755
--- a/xos/core/xoslib/methods/loginview.py
+++ b/xos/core/xoslib/methods/loginview.py
@@ -1,7 +1,7 @@
from rest_framework.decorators import api_view
from rest_framework.response import Response
from rest_framework.reverse import reverse
-from django.core import serializers
+from rest_framework import serializers
from rest_framework import generics
from rest_framework.views import APIView
from core.models import *
@@ -15,9 +15,9 @@
import time
import django.middleware.csrf
from xos.exceptions import *
-from django.forms.models import model_to_dict
from django.contrib.sessions.backends.db import SessionStore
from django.contrib.sessions.models import Session
+from django.contrib.auth import authenticate
def date_handler(obj):
return obj.isoformat() if hasattr(obj, 'isoformat') else obj
@@ -39,17 +39,14 @@
if not password:
raise XOSMissingField("No password specified")
- u = User.objects.filter(email=username)
+ u=authenticate(username=username, password=password)
if not u:
- raise PermissionDenied("Permission Denied")
-
- u=u[0]
-
- if not u.check_password(password):
- raise PermissionDenied("Permission Denied")
+ raise PermissionDenied("Failed to authenticate user %s" % username)
auth = {"username": username, "password": password}
request.session["auth"] = auth
+ request.session['_auth_user_id'] = u.pk
+ request.session['_auth_user_backend'] = u.backend
request.session.save()
return Response({
@@ -89,6 +86,9 @@
if "auth" in session:
del session["auth"]
session.save()
+ if "_auth_user_id" in session:
+ del session["_auth_user_id"]
+ session.save()
return Response("Logged Out")
@@ -98,5 +98,4 @@
def post(self, request, format=None):
sessionid = request.DATA.get("xossessionid", None)
- return self.do_logout(request, sessionid)
-
+ return self.do_logout(request, sessionid)
\ No newline at end of file