signin form reset after successfull registration

parent 8d89f8dd
...@@ -400,7 +400,7 @@ module.exports = { ...@@ -400,7 +400,7 @@ module.exports = {
throw new Error("Not a valid supervisor") throw new Error("Not a valid supervisor")
// Get all stu_sup relations // Get all stu_sup relations
StuSup.find({ supervisor: supervisor.id }) StuSup.find({ id_sup: supervisor.id })
.populate('student') .populate('student')
.then(function (stuSups) { .then(function (stuSups) {
...@@ -428,6 +428,7 @@ module.exports = { ...@@ -428,6 +428,7 @@ module.exports = {
}, },
function(err) {} function(err) {}
); );
sails.debug.log("->"+students);
return students; return students;
}) })
.then(function (students) { .then(function (students) {
...@@ -449,8 +450,10 @@ module.exports = { ...@@ -449,8 +450,10 @@ module.exports = {
.catch(function (err) { .catch(function (err) {
res.serverError("Error " + err); res.serverError("Error " + err);
}); });
} else } else {
sails.debug.log(students);
res.ok(students); res.ok(students);
}
}) })
.catch(err => {throw err}); .catch(err => {throw err});
}) })
......
...@@ -60,7 +60,7 @@ function LoginCtrl( ...@@ -60,7 +60,7 @@ function LoginCtrl(
.post(config.backend + '/sup/login', $scope.credentials) .post(config.backend + '/sup/login', $scope.credentials)
.success(function (data) { .success(function (data) {
// default logo to Pictogram logo // default logo to Pictogram logo
if (data.user.office.logo_url.length < 5) if (!data.user.office || data.user.office.logo_url.length < 5)
data.user.office.logo_url = 'img/logo_pictogram.png'; data.user.office.logo_url = 'img/logo_pictogram.png';
$window.sessionStorage.token = data.token; $window.sessionStorage.token = data.token;
......
...@@ -13,6 +13,8 @@ function SignInCtrl($scope, ...@@ -13,6 +13,8 @@ function SignInCtrl($scope,
config, config,
CONSTANTS, CONSTANTS,
ngToast) { ngToast) {
$scope.reset = function () {
$scope.formdata = { $scope.formdata = {
name: '', name: '',
surname: '', surname: '',
...@@ -25,8 +27,10 @@ function SignInCtrl($scope, ...@@ -25,8 +27,10 @@ function SignInCtrl($scope,
password_confirm: '', password_confirm: '',
lang: 'es-es' lang: 'es-es'
}; };
};
reCAPTCHA.setPublicKey('6LdLjh0TAAAAANblo_KUGNnmRZuIetOkdjdhj1b6'); reCAPTCHA.setPublicKey('6LdLjh0TAAAAANblo_KUGNnmRZuIetOkdjdhj1b6');
$scope.reset();
// Form submit // Form submit
$scope.signin = function () { $scope.signin = function () {
...@@ -58,6 +62,7 @@ function SignInCtrl($scope, ...@@ -58,6 +62,7 @@ function SignInCtrl($scope,
.post(config.backend + '/sup', $scope.formdata) .post(config.backend + '/sup', $scope.formdata)
.success(function () { .success(function () {
ngToast.success({ content: $translate.instant('user_created') }); ngToast.success({ content: $translate.instant('user_created') });
$scope.reset();
}) })
.error(function () { .error(function () {
ngToast.danger({ content: $translate.instant('user_exists', {email: $scope.formdata.email}) }); ngToast.danger({ content: $translate.instant('user_exists', {email: $scope.formdata.email}) });
......
...@@ -117,6 +117,12 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl( ...@@ -117,6 +117,12 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl(
$scope.formUser.notes = data.notes; $scope.formUser.notes = data.notes;
$scope.formUser.surname = data.surname; $scope.formUser.surname = data.surname;
$scope.formUser.username = data.username; $scope.formUser.username = data.username;
// websocket emit vocabulary delete action
io.socket.post('/stu/config', {
action: 'update',
attributes: data
}, function () {});
}) })
.error(function () { .error(function () {
$translate.danger('student_not_updated', function (translation) { $translate.danger('student_not_updated', function (translation) {
...@@ -302,6 +308,14 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl( ...@@ -302,6 +308,14 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl(
$translate('attributes_updated').then(function (translation) { $translate('attributes_updated').then(function (translation) {
ngToast.success({ content: translation }); ngToast.success({ content: translation });
}); });
// websocket emit vocabulary delete action
io.socket.post('/stu/config', {
action: 'update',
attributes: {
id_stu: $scope.studentData.id,
attributes: $scope.studentData.attributes
}
}, function () {});
}) })
.error(function () { .error(function () {
$translate('attributes_not_updated').then(function (translation) { $translate('attributes_not_updated').then(function (translation) {
......
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