signin form reset after successfull registration

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