alta y login para tutor y therapist funcionando

parent ed54ade1
...@@ -221,7 +221,6 @@ module.exports = { ...@@ -221,7 +221,6 @@ module.exports = {
var l = []; var l = [];
Supervisor.findOne(id) Supervisor.findOne(id)
.populate('office')
.then(function (sup) { .then(function (sup) {
if (!sup) if (!sup)
throw new Error("Not a valid supervisor") throw new Error("Not a valid supervisor")
...@@ -265,38 +264,9 @@ module.exports = { ...@@ -265,38 +264,9 @@ module.exports = {
next_cb(); next_cb();
}); });
}, },
function (err) { // loop has end function (err) {
// Get all students from the office if user is administrator
if (sup.office && sup.office.admin == sup.id) {
var officeStudents;
Student.find({ office: sup.office.id })
.populate('lastInstruction')
.populate('license')
.then(function (officeStudents) {
officeStudents = officeStudents.map((student) => {
student.supervision = 0;
student.current_method = student.lastInstruction[0] ? student.lastInstruction[0].met_name : "no_method";
student.current_instruction = student.lastInstruction[0] ? student.lastInstruction[0].ins_name : "no_instruction";
if (typeof(student.license[0]) != 'undefined') {
student.licenseIsValid = new Date(student.license[0].expiration_ts) - new Date() > 0 ? true : false;
student.license = student.license[0];
} else {
student.licenseIsValid = false;
student.license = null;
}
return student;
});
l = l.concat(officeStudents);
callback(err, lodash.uniq(l, false, 'id'));
})
.catch(function (err) {
callback(err, l);
});
} else {
callback(err, l); callback(err, l);
} });
}); // end async.eachSeries
}) })
.catch((err) => { .catch((err) => {
callback(err, l); callback(err, l);
......
...@@ -32,8 +32,9 @@ dashboardControllers.controller('MainCtrl', function MainCtrl($scope, $window, $ ...@@ -32,8 +32,9 @@ dashboardControllers.controller('MainCtrl', function MainCtrl($scope, $window, $
id: '', id: '',
name: '', name: '',
surname: '', surname: '',
email: '',
role: '',
pic: '', pic: '',
office: '',
lang: '' lang: ''
}; };
......
...@@ -77,16 +77,10 @@ function LoginCtrl( ...@@ -77,16 +77,10 @@ function LoginCtrl(
$translate.use($scope.lang); $translate.use($scope.lang);
} else { } else {
$translate.use($scope.lang); $translate.use($scope.lang);
$location.path('/sup/login');
} }
// Change
$window.sessionStorage.user = JSON.stringify(data.user); $window.sessionStorage.user = JSON.stringify(data.user);
ngToast.success($translate('login_success'));
// Name in login success message
$scope.name = data.user.name || data.user.email;
// Redirección
$location.path('/students'); $location.path('/students');
}) })
.error(function (err) { .error(function (err) {
......
...@@ -270,7 +270,6 @@ ...@@ -270,7 +270,6 @@
</div> </div>
<fieldset> <fieldset>
<label translate>password</label> <label translate>password</label>
<span class="color_red text_sm pull-right" ng-show="formdata.password != formdata.password_confirm" translate>password_match</span>
<div class="form-group"> <div class="form-group">
<input type="password" class="form-control" id="signin_password1" placeholder="{{ 'password_type' | translate }}" name="password" required ng-model="formdata.password"/> <input type="password" class="form-control" id="signin_password1" placeholder="{{ 'password_type' | translate }}" name="password" required ng-model="formdata.password"/>
<span class="color_red text_sm pull-right" ng-show="formdata.password.length < minlength && forms.officeForm.password.$dirty && forms.officeForm.password_confirm.$dirty"> {{ 'password_short' | translate:'{ minlength: minlength }' }}</span> <span class="color_red text_sm pull-right" ng-show="formdata.password.length < minlength && forms.officeForm.password.$dirty && forms.officeForm.password_confirm.$dirty"> {{ 'password_short' | translate:'{ minlength: minlength }' }}</span>
......
...@@ -124,6 +124,8 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl( ...@@ -124,6 +124,8 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl(
user.phone = data.phone; user.phone = data.phone;
user.email = data.email; user.email = data.email;
user.lang = data.lang; user.lang = data.lang;
user.pic = data.pic;
user.role = data.role;
// Delete because at the beginning the variable user is bind // Delete because at the beginning the variable user is bind
// with the form // with the form
......
...@@ -25,8 +25,8 @@ dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl( ...@@ -25,8 +25,8 @@ dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl(
// Assign values this way (like an object) to ensure it's the parent scope // Assign values this way (like an object) to ensure it's the parent scope
$scope.user.id = user.id; $scope.user.id = user.id;
$scope.user.role = user.role; $scope.user.role = user.role;
$scope.user.name = user.name; $scope.user.name = user.name || $translate.instant('name');
$scope.user.surname = user.surname; $scope.user.surname = user.surname || $translate.instant('surname');
$scope.user.pic = user.pic; $scope.user.pic = user.pic;
$scope.user.lang = user.lang; $scope.user.lang = user.lang;
$scope.user.isOffice = user.isOffice; $scope.user.isOffice = user.isOffice;
......
...@@ -8,16 +8,15 @@ ...@@ -8,16 +8,15 @@
href="/app/#/students"> href="/app/#/students">
<img <img
class="topbar__logo__image" class="topbar__logo__image"
ng-src="{{user.office.logoUrl}}" src="/app/img/logo_pictogram.png"
alt="{{user.office.name}}" alt="Pîctogram"
title="{{user.office.name}}" /> title="Pictogram" />
</a> </a>
</div> </div>
<div class="topbar__supervisor nav navbar-nav navbar-right"> <div class="topbar__supervisor nav navbar-nav navbar-right">
<div class="dropdown"> <div class="dropdown">
<div class="topbar__supervisor__name"> <div class="topbar__supervisor__name">
<div class="topbar__supervisor__name__fullname">{{user.getFullName()}}</div> <div class="topbar__supervisor__name__fullname">{{user.getFullName()}}</div>
<div class="topbar__supervisor__name__office">{{user.office.name}}</div>
</div> </div>
<div <div
class="topbar__supervisor__avatar thumbnail" class="topbar__supervisor__avatar thumbnail"
......
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