update of user data after submission

parent 56104a53
...@@ -23,20 +23,8 @@ var dashboardControllers = angular.module('dashboardControllers', ['dashboardCon ...@@ -23,20 +23,8 @@ var dashboardControllers = angular.module('dashboardControllers', ['dashboardCon
// Main Controller // Main Controller
// //
// //
dashboardControllers.controller('MainCtrl', function MainCtrl($scope, $window, $location, $translate, $rootScope, $timeout) { dashboardControllers.controller('MainCtrl', function MainCtrl(
$scope, $window, $location, $translate, $rootScope, $timeout, user) {
// Always use objects if we want to modify this scope in the childs
// Save name and surname in global scope
$scope.user = {
id: '',
name: '',
surname: '',
email: '',
role: '',
pic: '',
lang: ''
};
// Use browser language as default // Use browser language as default
var lang = $window.navigator.language || $window.navigator.userLanguage; var lang = $window.navigator.language || $window.navigator.userLanguage;
...@@ -74,7 +62,7 @@ dashboardControllers.controller('MainCtrl', function MainCtrl($scope, $window, $ ...@@ -74,7 +62,7 @@ dashboardControllers.controller('MainCtrl', function MainCtrl($scope, $window, $
// //
// Logout // Logout
$scope.logout = function(){ $scope.logout = function() {
delete $window.sessionStorage.token; delete $window.sessionStorage.token;
delete $window.sessionStorage.user; delete $window.sessionStorage.user;
......
...@@ -3,9 +3,13 @@ ...@@ -3,9 +3,13 @@
//-------------------------- //--------------------------
// Admin License Controller // Admin License Controller
//-------------------------- //--------------------------
dashboardControllers.controller('AdminLicensesCtrl', function AdminLicensesCtrl($scope, $window, $http, config, $translate, ngToast) { dashboardControllers.controller('AdminLicensesCtrl', function AdminLicensesCtrl(
$rootScope,
$scope, $window, $http, config, $translate, ngToast) {
// The parameter 'config' is injected from config.js (defined in dashboardConfig module) // The parameter 'config' is injected from config.js (defined in dashboardConfig module)
$scope.user = $rootScope.user;
// Don't show the message at the begining // Don't show the message at the begining
$scope.showmessagesupervisor = false; $scope.showmessagesupervisor = false;
$scope.new_numbers = []; $scope.new_numbers = [];
......
...@@ -18,7 +18,6 @@ function LoginCtrl( ...@@ -18,7 +18,6 @@ function LoginCtrl(
$stateParams, $stateParams,
$timeout, $timeout,
ngToast, ngToast,
user,
CONSTANTS, CONSTANTS,
vcRecaptchaService) { vcRecaptchaService) {
...@@ -78,7 +77,7 @@ function LoginCtrl( ...@@ -78,7 +77,7 @@ function LoginCtrl(
// user is in the scope of the MainCtrl // user is in the scope of the MainCtrl
data.user.name = data.user.name || $translate.instant('name'); data.user.name = data.user.name || $translate.instant('name');
data.user.surname = data.user.surname || $translate.instant('surname'); data.user.surname = data.user.surname || $translate.instant('surname');
$scope.user = JSON.parse(JSON.stringify(data.user)); $rootScope.user = JSON.parse(JSON.stringify(data.user));
$window.sessionStorage.user = JSON.stringify(data.user); $window.sessionStorage.user = JSON.stringify(data.user);
$location.path('/students'); $location.path('/students');
}) })
......
...@@ -19,6 +19,9 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -19,6 +19,9 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$modal, $modal,
$translate, $translate,
ngToast) { ngToast) {
$scope.user = $rootScope.user;
$scope.emptyStudentPicto = { $scope.emptyStudentPicto = {
id: null, id: null,
picto: { picto: {
......
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
//----------------------- //-----------------------
// Student Instructions Controller // Student Instructions Controller
//----------------------- //-----------------------
dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstructionsCtrl($scope, $stateParams, $http, config, $window, $translate, $modal, ngToast, newconfirm) { dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstructionsCtrl(
$rootScope, $scope, $stateParams, $http, config, $window, $translate, $modal, ngToast, newconfirm) {
$scope.user = $rootScope.user;
// For tab navigation (here too, if the user refresh the page...) // For tab navigation (here too, if the user refresh the page...)
$scope.nav.tab = 'instructions'; $scope.nav.tab = 'instructions';
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
// Student Session Controller // Student Session Controller
//----------------------- //-----------------------
dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtrl( dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtrl(
$rootScope,
$scope, $scope,
$stateParams, $stateParams,
$http, $http,
...@@ -12,6 +13,8 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -12,6 +13,8 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$translate, $translate,
ngToast) { ngToast) {
$scope.user = $rootScope.user;
// For tab navigation (here too, if the user refresh the page...) // For tab navigation (here too, if the user refresh the page...)
$scope.nav.tab = 'session'; $scope.nav.tab = 'session';
......
...@@ -18,6 +18,8 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl( ...@@ -18,6 +18,8 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl(
config, config,
CONSTANTS) { CONSTANTS) {
$scope.user = $rootScope.user;
// Don't show the message at the begining // Don't show the message at the begining
$scope.showmessage = false; $scope.showmessage = false;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
* StudentsCtrl * StudentsCtrl
*/ */
dashboardControllers.controller('StudentsCtrl', function StudentsCtrl( dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
$rootScope,
$scope, $scope,
$state, $state,
$http, $http,
...@@ -17,9 +18,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl( ...@@ -17,9 +18,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
IOService, IOService,
CONSTANTS) { CONSTANTS) {
$scope.user = $rootScope.user;
// Flags for showing buttons according to role
$scope.user = JSON.parse($window.sessionStorage.user);
// -------------------------------------------------------- // --------------------------------------------------------
// Create new account // Create new account
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
// Supervisor Controller // Supervisor Controller
//----------------------- //-----------------------
dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl( dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl(
$rootScope,
$scope, $scope,
$http, $http,
config, config,
...@@ -20,7 +21,7 @@ dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl( ...@@ -20,7 +21,7 @@ dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl(
if (!$window.sessionStorage.user) if (!$window.sessionStorage.user)
return $scope.logout(); return $scope.logout();
$scope.user = JSON.parse($window.sessionStorage.user); $scope.user = $rootScope.user;
// Link to setup // Link to setup
$scope.setup = function(){ $scope.setup = function(){
......
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
//-------------------------- //--------------------------
// Admin Supervisors Controller // Admin Supervisors Controller
//-------------------------- //--------------------------
dashboardControllers.controller('SupervisorsCtrl', function SupervisorsCtrl($scope, $window, $http, config, $translate, ngToast) { dashboardControllers.controller('SupervisorsCtrl', function SupervisorsCtrl(
$rootScope, $scope, $window, $http, config, $translate, ngToast) {
$scope.user = $rootScope.user;
$scope.inputs = { $scope.inputs = {
search_str: '', search_str: '',
......
...@@ -31,14 +31,6 @@ module.factory('AuthInterceptorService', function ($rootScope, $q, $window) { ...@@ -31,14 +31,6 @@ module.factory('AuthInterceptorService', function ($rootScope, $q, $window) {
}; };
}); });
/**
* 'user' service, to make user information persists through ui-route
* This is a more convenient way that user $window.sessionStorage
*/
module.factory("user",function(){
return {};
});
// Add AuthInterceptorService to $httpProvider.interceptors // Add AuthInterceptorService to $httpProvider.interceptors
module.config(function ($httpProvider) { module.config(function ($httpProvider) {
$httpProvider.interceptors.push('AuthInterceptorService'); $httpProvider.interceptors.push('AuthInterceptorService');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment