update of user data after submission

parent 56104a53
......@@ -23,20 +23,8 @@ var dashboardControllers = angular.module('dashboardControllers', ['dashboardCon
// Main Controller
//
//
dashboardControllers.controller('MainCtrl', function MainCtrl($scope, $window, $location, $translate, $rootScope, $timeout) {
// 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: ''
};
dashboardControllers.controller('MainCtrl', function MainCtrl(
$scope, $window, $location, $translate, $rootScope, $timeout, user) {
// Use browser language as default
var lang = $window.navigator.language || $window.navigator.userLanguage;
......@@ -74,7 +62,7 @@ dashboardControllers.controller('MainCtrl', function MainCtrl($scope, $window, $
//
// Logout
$scope.logout = function(){
$scope.logout = function() {
delete $window.sessionStorage.token;
delete $window.sessionStorage.user;
......
......@@ -3,9 +3,13 @@
//--------------------------
// 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)
$scope.user = $rootScope.user;
// Don't show the message at the begining
$scope.showmessagesupervisor = false;
$scope.new_numbers = [];
......
......@@ -18,7 +18,6 @@ function LoginCtrl(
$stateParams,
$timeout,
ngToast,
user,
CONSTANTS,
vcRecaptchaService) {
......@@ -78,7 +77,7 @@ function LoginCtrl(
// user is in the scope of the MainCtrl
data.user.name = data.user.name || $translate.instant('name');
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);
$location.path('/students');
})
......
......@@ -19,6 +19,9 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$modal,
$translate,
ngToast) {
$scope.user = $rootScope.user;
$scope.emptyStudentPicto = {
id: null,
picto: {
......
......@@ -3,7 +3,10 @@
//-----------------------
// 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...)
$scope.nav.tab = 'instructions';
......
......@@ -4,6 +4,7 @@
// Student Session Controller
//-----------------------
dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtrl(
$rootScope,
$scope,
$stateParams,
$http,
......@@ -12,6 +13,8 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$translate,
ngToast) {
$scope.user = $rootScope.user;
// For tab navigation (here too, if the user refresh the page...)
$scope.nav.tab = 'session';
......
......@@ -18,6 +18,8 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl(
config,
CONSTANTS) {
$scope.user = $rootScope.user;
// Don't show the message at the begining
$scope.showmessage = false;
......
......@@ -6,6 +6,7 @@
* StudentsCtrl
*/
dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
$rootScope,
$scope,
$state,
$http,
......@@ -17,9 +18,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
IOService,
CONSTANTS) {
// Flags for showing buttons according to role
$scope.user = JSON.parse($window.sessionStorage.user);
$scope.user = $rootScope.user;
// --------------------------------------------------------
// Create new account
......
......@@ -6,6 +6,7 @@
// Supervisor Controller
//-----------------------
dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl(
$rootScope,
$scope,
$http,
config,
......@@ -20,7 +21,7 @@ dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl(
if (!$window.sessionStorage.user)
return $scope.logout();
$scope.user = JSON.parse($window.sessionStorage.user);
$scope.user = $rootScope.user;
// Link to setup
$scope.setup = function(){
......
......@@ -3,7 +3,10 @@
//--------------------------
// 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 = {
search_str: '',
......
......@@ -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
module.config(function ($httpProvider) {
$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