alta y login para tutor y therapist funcionando

parent ed54ade1
......@@ -221,7 +221,6 @@ module.exports = {
var l = [];
Supervisor.findOne(id)
.populate('office')
.then(function (sup) {
if (!sup)
throw new Error("Not a valid supervisor")
......@@ -265,38 +264,9 @@ module.exports = {
next_cb();
});
},
function (err) { // loop has end
// 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 {
function (err) {
callback(err, l);
}
}); // end async.eachSeries
});
})
.catch((err) => {
callback(err, l);
......
......@@ -32,8 +32,9 @@ dashboardControllers.controller('MainCtrl', function MainCtrl($scope, $window, $
id: '',
name: '',
surname: '',
email: '',
role: '',
pic: '',
office: '',
lang: ''
};
......
......@@ -77,16 +77,10 @@ function LoginCtrl(
$translate.use($scope.lang);
} else {
$translate.use($scope.lang);
$location.path('/sup/login');
}
// Change
$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');
})
.error(function (err) {
......
......@@ -270,7 +270,6 @@
</div>
<fieldset>
<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">
<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>
......
......@@ -124,6 +124,8 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl(
user.phone = data.phone;
user.email = data.email;
user.lang = data.lang;
user.pic = data.pic;
user.role = data.role;
// Delete because at the beginning the variable user is bind
// with the form
......
......@@ -25,8 +25,8 @@ dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl(
// Assign values this way (like an object) to ensure it's the parent scope
$scope.user.id = user.id;
$scope.user.role = user.role;
$scope.user.name = user.name;
$scope.user.surname = user.surname;
$scope.user.name = user.name || $translate.instant('name');
$scope.user.surname = user.surname || $translate.instant('surname');
$scope.user.pic = user.pic;
$scope.user.lang = user.lang;
$scope.user.isOffice = user.isOffice;
......
......@@ -8,16 +8,15 @@
href="/app/#/students">
<img
class="topbar__logo__image"
ng-src="{{user.office.logoUrl}}"
alt="{{user.office.name}}"
title="{{user.office.name}}" />
src="/app/img/logo_pictogram.png"
alt="Pîctogram"
title="Pictogram" />
</a>
</div>
<div class="topbar__supervisor nav navbar-nav navbar-right">
<div class="dropdown">
<div class="topbar__supervisor__name">
<div class="topbar__supervisor__name__fullname">{{user.getFullName()}}</div>
<div class="topbar__supervisor__name__office">{{user.office.name}}</div>
</div>
<div
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