From ce8efbcaa99ff685bc90cd0057bdba55282f9108 Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Sun, 14 Jun 2015 20:06:00 +0300 Subject: [PATCH 1/3] Email verification added- empty user name test added --- .../js/controllers/registerController.js | 51 ++++++------------- 1 file changed, 16 insertions(+), 35 deletions(-) diff --git a/templates/js/controllers/registerController.js b/templates/js/controllers/registerController.js index c8cadcf..5be6f7f 100644 --- a/templates/js/controllers/registerController.js +++ b/templates/js/controllers/registerController.js @@ -1,25 +1,19 @@ angular.module('SeHub') -.controller('registerController', ['$scope', '$location', '$cookies', 'apiService', '$rootScope', function ($scope, $location, $cookies, apiService ,$rootScope) { +.controller('registerController', ['$scope', '$cookies', 'apiService', '$rootScope', function ($scope, $cookies, apiService ,$rootScope) { $scope.userHasNoName = false; $scope.campusChecked = false; $scope.isEmpty = true; // if the academic email line is empty - // $scope.fullMail = $scope.academicEmail + $scope.campusObj.email_ending; // Will hold the full academic email of the user $rootScope.seToken = $cookies['com.sehub.www']; var token = $rootScope.seToken; apiService.getUserByToken(token).success(function(data){ $scope.user = data; - console.log(data); + if(data.message == 'No User Found') console.error("No User Found!"); - - $scope.user = data; - $rootScope.user = data; - if($scope.user.isFirstLogin) - $location.path('/register') - + console.log(data); if($scope.user.name === ";"){ $scope.user.name = ""; @@ -38,8 +32,6 @@ angular.module('SeHub') }); - - $scope.dropdownClicked = function() { if($scope.campus){ @@ -51,37 +43,26 @@ angular.module('SeHub') console.log($scope.campusObj); // TODO REMOVE!! } }; - } - + }; }; $scope.submitClicked = function() { - console.log($scope.user.AcMail); - $scope.mail = 'pin'; - console.log($scope.mail); + if($scope.user.AcMail != null) + { + var fullMail = $scope.user.AcMail + $scope.campusObj.email_ending; // Holds the full academic email of the user + apiService.sendValidationMail($scope.user.seToken, fullMail).success(function(data) // TODO: Add 2nd parameter email type Email + { + console.log("DONE - 200"); + // TODO - add a window that display that an email has been sent for verification + }).error(function() + { + // TODO + }); + }; }; - - apiService.getAllCampuses($scope.user.seToken).success(function(data) - { - $scope.campuses = data; - }).error(function() - { - // TODO - }); - - // apiService.sendValidationMail($scope.user.seToken, $scope.fullMail).success(function(data) // TODO: Add 2nd parameter email type Email - // { - // console.log($scope.fullMail); - // console.log("200"); - - // // TODO - // }).error(function() - // { - - // }); From cadb95651ed603bc31644a291fda87f81d8e1dfd Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Sun, 14 Jun 2015 20:22:00 +0300 Subject: [PATCH 2/3] Email verification added- empty user name test added --- templates/js/controllers/registerController.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/templates/js/controllers/registerController.js b/templates/js/controllers/registerController.js index 5be6f7f..5c93628 100644 --- a/templates/js/controllers/registerController.js +++ b/templates/js/controllers/registerController.js @@ -8,7 +8,8 @@ angular.module('SeHub') $rootScope.seToken = $cookies['com.sehub.www']; var token = $rootScope.seToken; - apiService.getUserByToken(token).success(function(data){ + apiService.getUserByToken(token).success(function(data) // Get user token + { $scope.user = data; if(data.message == 'No User Found') @@ -21,7 +22,7 @@ angular.module('SeHub') $scope.userHasNoName = true; } - apiService.getAllCampuses($scope.user.seToken).success(function(data) + apiService.getAllCampuses($scope.user.seToken).success(function(data) // Get all the campuses { $scope.campuses = data; }).error(function() From c3e39e895a37e5fc03cef499a1c5fe91ce5e0aba Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Sun, 14 Jun 2015 22:06:27 +0300 Subject: [PATCH 3/3] registration submit skeleton --- .../js/controllers/registerController.js | 58 ++++++++++++++----- templates/views/register.html | 6 +- 2 files changed, 45 insertions(+), 19 deletions(-) diff --git a/templates/js/controllers/registerController.js b/templates/js/controllers/registerController.js index 5c93628..5c5e7b0 100644 --- a/templates/js/controllers/registerController.js +++ b/templates/js/controllers/registerController.js @@ -1,5 +1,6 @@ angular.module('SeHub') -.controller('registerController', ['$scope', '$cookies', 'apiService', '$rootScope', function ($scope, $cookies, apiService ,$rootScope) { +.controller('registerController', ['$scope', '$cookies', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $location, $mdToast, $mdDialog, apiService ,$rootScope) +{ $scope.userHasNoName = false; $scope.campusChecked = false; @@ -16,23 +17,23 @@ angular.module('SeHub') console.error("No User Found!"); console.log(data); - if($scope.user.name === ";"){ + if($scope.user.name === ";") + { $scope.user.name = ""; $scope.user.name = $scope.user.username $scope.userHasNoName = true; } - apiService.getAllCampuses($scope.user.seToken).success(function(data) // Get all the campuses - { - $scope.campuses = data; - }).error(function() - { - // TODO - }); + apiService.getAllCampuses($scope.user.seToken).success(function(data) // Get all the campuses + { + $scope.campuses = data; + }).error(function() + { + // TODO + }); }); - $scope.dropdownClicked = function() { if($scope.campus){ @@ -47,26 +48,51 @@ angular.module('SeHub') }; }; - $scope.submitClicked = function() + $scope.submitClicked = function(ev) { if($scope.user.AcMail != null) { var fullMail = $scope.user.AcMail + $scope.campusObj.email_ending; // Holds the full academic email of the user - apiService.sendValidationMail($scope.user.seToken, fullMail).success(function(data) // TODO: Add 2nd parameter email type Email + apiService.sendValidationMail($scope.user.seToken, fullMail).success(function(data) { - console.log("DONE - 200"); - // TODO - add a window that display that an email has been sent for verification + console.log("DONE - 200"); + $mdDialog.show($mdDialog.alert().title('E-mail Verification').content('A verification e-mail has been sent to your email address.') + .ariaLabel('Email verification alert dialog').ok('Got it!').targetEvent(ev)); + // TODO - ADD DELETE COOKIES + $cookies.remove("com.sehub.www"); + // $location.path("templates/views/home.html"); // Redirecting to home page // TODO REMOVE REMOVE!! }).error(function() { - // TODO + $mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address.') + .ariaLabel('Email verification error alert dialog').ok('Got it!').targetEvent(ev)); }); }; }; + // TODO FOR LATER + // TODO FOR LATER + $scope.getPopWindowPosition = function() + { + return Object.keys($scope.toastPosition).filter(function(pos) + { + return $scope.toastPosition[pos]; + }).join(' '); + }; + + $scope.toastPosition = + { + bottom: false, + top: true, + left: false, + right: true + }; + + // TODO FOR LATER + // TODO FOR LATER +}]); -}]); \ No newline at end of file diff --git a/templates/views/register.html b/templates/views/register.html index bbe6b26..d73d0d9 100644 --- a/templates/views/register.html +++ b/templates/views/register.html @@ -18,8 +18,8 @@
Are You A Lecturer? - - + +
@@ -37,7 +37,7 @@
- Submit + Submit