Commit ffa4f5d8 authored by Ασπασία Κατσή's avatar Ασπασία Κατσή

Merge branch 'distribution' into 'develop'

Distribution

See merge request itminedu/e-eggrafes!117
parents 7f02de2e dcf6dab7
......@@ -217,11 +217,18 @@ class CASLogin extends ControllerBase
$schools = $this->entityTypeManager->getStorage('gel_school')->loadByProperties(array('registry_no' => $registry_no));
$school = reset($schools);
if ($school) {
if ($school->unit_type_id->value =="3"){
if (($school->unit_type_id->value ==="3" )&&($school->extra_unitid->value !=="200")){
return array("id" => $school->id(), "exposedRole" => "director_gym", "internalRole" => "gym");
}
elseif (($school->unit_type_id->value ==="3") && ($school->extra_unitid->value ==="200"))
{
return array("id" => $school->id(), "exposedRole" => "director_gymlt", "internalRole" => "gymlt");
}
else{
return array("id" => $school->id(), "exposedRole" => "director_gel", "internalRole" => "gel");
return array("id" => $school->id(), "exposedRole" => "director_gel", "internalRole" => "gel");
}
}
$eduAdmins = $this->entityTypeManager->getStorage('eepal_admin_area')->loadByProperties(array('registry_no' => $registry_no));
......
......@@ -71,7 +71,7 @@ class CurrentUser extends ControllerBase
$userRoles = $user->getRoles();
foreach ($userRoles as $userRole) {
if (($userRole === 'epal') ||($userRole === 'gel') || ($userRole === 'regioneduadmin') || ($userRole === 'eduadmin') || ($userRole === 'gym')) {
if (($userRole === 'epal') ||($userRole === 'gel') || ($userRole === 'regioneduadmin') || ($userRole === 'eduadmin') || ($userRole === 'gym') || ($userRole === 'gymlt')) {
return $this->respondWithStatus([
'cu_name' => $user->mail->value,
'cu_surname' => '',
......
......@@ -46,6 +46,7 @@ import { LoaderService } from "./services/Spinner.service";
import SchoolGymAuthGuard from "./guards/schoolgym.auth.guard";
import * as $ from "jquery";
class MyLocalization extends NgLocalization {
......@@ -101,7 +102,8 @@ class MyLocalization extends NgLocalization {
DidepdeAuthGuard,
MinistryAuthGuard,
ReportsAuthGuard,
SchoolGymAuthGuard
SchoolGymAuthGuard,
]
})
class AppModule { }
......
......@@ -71,6 +71,7 @@ import { LocalDataSource } from "ng2-smart-table";
}
ngOnInit() {
this.validCreator = 0;
this.showLoader.next(true);
......
......@@ -16,7 +16,7 @@ import { OrientationGroupActions } from "../../actions/orientationgroup.action";
import { LangCourseFieldsActions } from "../../actions/langcoursesfields.actions";
import { GelStudentDataFieldsActions } from "../../actions/gelstudentdatafields.actions";
import { DIDE_ROLE, MINISTRY_ROLE, PDE_ROLE, SCHOOL_ROLE, STUDENT_ROLE, SCHOOLGEL_ROLE, SCHOOLGYM_ROLE } from "../../constants";
import { DIDE_ROLE, MINISTRY_ROLE, PDE_ROLE, SCHOOL_ROLE, STUDENT_ROLE, SCHOOLGEL_ROLE, SCHOOLGYM_ROLE, SCHOOLGYMLT_ROLE} from "../../constants";
import { HelperDataService } from "../../services/helper-data-service";
import { LOGININFO_INITIAL_STATE } from "../../store/logininfo/logininfo.initial-state";
import { ILoginInfoRecords } from "../../store/logininfo/logininfo.types";
......@@ -118,7 +118,7 @@ export default class HeaderComponent implements OnInit, OnDestroy {
this.showLoader$.next(true);
this._hds.signOut().then(data => {
this._ata.initLoginInfo();
if (this.authRole === SCHOOL_ROLE || this.authRole === SCHOOLGEL_ROLE || this.authRole === SCHOOLGYM_ROLE) {
if (this.authRole === SCHOOL_ROLE || this.authRole === SCHOOLGEL_ROLE || this.authRole === SCHOOLGYM_ROLE || this.authRole === SCHOOLGYMLT_ROLE) {
this.authToken = "";
this.authRole = "";
window.location.assign((<any>data).next);
......@@ -160,7 +160,7 @@ export default class HeaderComponent implements OnInit, OnDestroy {
}
goHome() {
if (this.authRole === SCHOOL_ROLE || this.authRole === SCHOOLGEL_ROLE || this.authRole === SCHOOLGYM_ROLE) {
if (this.authRole === SCHOOL_ROLE || this.authRole === SCHOOLGEL_ROLE || this.authRole === SCHOOLGYM_ROLE || this.authRole === SCHOOLGYMLT_ROLE) {
this.router.navigate(["/school"]);
}
else if (this.authRole === PDE_ROLE) {
......
......@@ -33,18 +33,18 @@
</div>
<div *ngIf="(loginInfo$ | async).size > 0 " class="nav-item" >
<li *ngIf="authRole=='director_gym'" class="nav-item">
<li *ngIf="(authRole=='director_gym') || (authRole=='director_gymlt')" class="nav-item">
<a class="nav-link" [routerLink]="['/school/directorgym-view']" [routerLinkActive]="['active']"><b>Λίστα Μαθητών</b></a>
</li>
</div>
<div *ngIf="(loginInfo$ | async).size > 0 " class="nav-item" >
<li *ngIf="authRole=='director_gel'" class="nav-item">
<li *ngIf="(authRole=='director_gel') || (authRole=='director_gymlt') " class="nav-item">
<a class="nav-link" [routerLink]="['/school/directorgel-view']" [routerLinkActive]="['active']"><b>Δηλώσεις Μαθητών</b></a>
</li>
</div>
<div *ngIf="(loginInfo$ | async).size > 0 " class="nav-item" >
<li *ngIf="authRole=='director_gel'" class="nav-item">
<li *ngIf="(authRole=='director_gel') || (authRole=='director_gymlt')" class="nav-item">
<a class="nav-link" [routerLink]="['/school/directorgel-reports']" [routerLinkActive]="['active']"><b>Αναφορές</b></a>
</li>
</div>
......
......@@ -159,13 +159,17 @@ export default class SchoolHome implements OnInit, OnDestroy {
}
else if (this.authRole === "director_gel")
{
this.router.navigate(["/school/directorgel-view"]); }
else if (this.authRole === "director_gym")
this.router.navigate(["/school/directorgel-view"]);
}
else if (this.authRole === "director_gym" || this.authRole === "director_gymlt" )
{
this.router.navigate(["/school/directorgym-view"]); }
this.router.navigate(["/school/directorgym-view"]);
}
else if (this.authRole === "pde")
{
this.router.navigate(["/school/perfecture-view"]); }
this.router.navigate(["/school/perfecture-view"]);
}
else if (this.authRole === "dide")
this.router.navigate(["/school/school-type-selection"]);
......
......@@ -88,6 +88,7 @@ export const VALID_DATE_PATTERN = "([1-9]|0[1-9]|[12][0-9]|3[01])[- /.]([1-9]|0[
export const SCHOOL_ROLE = "director";
export const SCHOOLGEL_ROLE = "director_gel";
export const SCHOOLGYMLT_ROLE = "director_gymlt";
export const SCHOOLGYM_ROLE = "director_gym";
export const STUDENT_ROLE = "student";
export const PDE_ROLE = "pde";
......
......@@ -2,7 +2,7 @@ import { Injectable } from "@angular/core";
import { CanActivate } from "@angular/router";
import { Router } from "@angular/router";
import { SCHOOLGEL_ROLE } from "../constants";
import { SCHOOLGEL_ROLE ,SCHOOLGYMLT_ROLE} from "../constants";
import { AuthService } from "../services/auth.service";
@Injectable()
......@@ -11,7 +11,7 @@ export default class SchoolGelStudentsLockedGuard implements CanActivate {
constructor(private authService: AuthService, private router: Router) { }
canActivate() {
return this.authService.isGelStudentsLocked(SCHOOLGEL_ROLE).then(isLocked => {
return this.authService.isGelStudentsLockedforTworoles(SCHOOLGEL_ROLE,SCHOOLGYMLT_ROLE).then(isLocked => {
if (isLocked) {
this.router.navigate(["/school"]);
return false;
......
......@@ -2,7 +2,7 @@ import { Injectable } from "@angular/core";
import { CanActivate } from "@angular/router";
import { Router } from "@angular/router";
import { SCHOOLGYM_ROLE } from "../constants";
import { SCHOOLGYM_ROLE,SCHOOLGYMLT_ROLE } from "../constants";
import { AuthService } from "../services/auth.service";
@Injectable()
......@@ -11,7 +11,7 @@ export default class SchoolGymStudentsLockedGuard implements CanActivate {
constructor(private authService: AuthService, private router: Router) { }
canActivate() {
return this.authService.isGelStudentsLocked(SCHOOLGYM_ROLE).then(isLocked => {
return this.authService.isGelStudentsLockedforTworoles(SCHOOLGYM_ROLE,SCHOOLGYMLT_ROLE).then(isLocked => {
if (isLocked) {
this.router.navigate(["/school"]);
return false;
......
......@@ -2,7 +2,7 @@ import { Injectable } from "@angular/core";
import { CanActivate } from "@angular/router";
import { Router } from "@angular/router";
import { SCHOOLGEL_ROLE } from "../constants";
import { SCHOOLGEL_ROLE ,SCHOOLGYMLT_ROLE} from "../constants";
import { AuthService } from "../services/auth.service";
@Injectable()
......@@ -11,7 +11,7 @@ export default class SchoolGelAuthGuard implements CanActivate {
constructor(private authService: AuthService, private router: Router) { }
canActivate() {
return this.authService.isLoggedIn(SCHOOLGEL_ROLE).then(loggedIn => {
return this.authService.isLoggedInFortworoles(SCHOOLGEL_ROLE,SCHOOLGYMLT_ROLE).then(loggedIn => {
if (!loggedIn) {
this.router.navigate(["/school/logout"]);
}
......
......@@ -2,7 +2,7 @@ import { Injectable } from "@angular/core";
import { CanActivate } from "@angular/router";
import { Router } from "@angular/router";
import { SCHOOLGYM_ROLE } from "../constants";
import { SCHOOLGYM_ROLE, SCHOOLGYMLT_ROLE } from "../constants";
import { AuthService } from "../services/auth.service";
@Injectable()
......@@ -11,7 +11,7 @@ export default class SchoolGymAuthGuard implements CanActivate {
constructor(private authService: AuthService, private router: Router) { }
canActivate() {
return this.authService.isLoggedIn(SCHOOLGYM_ROLE).then(loggedIn => {
return this.authService.isLoggedInFortworoles(SCHOOLGYM_ROLE, SCHOOLGYMLT_ROLE).then(loggedIn => {
if (!loggedIn) {
this.router.navigate(["/school/logout"]);
}
......
......@@ -20,7 +20,7 @@ export class AuthService {
.subscribe(linfo => {
if (linfo.size > 0) {
linfo.reduce(({}, loginInfoObj) => {
linfo.reduce(({}, loginInfoObj) => {
if ((loginInfoObj.auth_token && loginInfoObj.auth_token.length > 0 && loginInfoObj.auth_role === role) ||
(loginInfoObj.minedu_username && loginInfoObj.minedu_username.length > 0 && loginInfoObj.auth_role === MINISTRY_ROLE && role === MINISTRY_ROLE)
) {
......@@ -28,6 +28,7 @@ export class AuthService {
}
else {
resolve(false);
}
return loginInfoObj;
}, {});
......@@ -41,6 +42,34 @@ export class AuthService {
});
}
isLoggedInFortworoles(role1, role2) {
return new Promise<boolean>((resolve, reject) => {
this._ngRedux.select("loginInfo")
.map(loginInfo => <ILoginInfoRecords>loginInfo)
.subscribe(loginInfo => {
if (loginInfo.size > 0) {
loginInfo.reduce(({}, loginInfoObj) => {
if ((loginInfoObj.auth_token && loginInfoObj.auth_token.length > 0 && (loginInfoObj.auth_role === role1 || loginInfoObj.auth_role === role2)) ||
(loginInfoObj.minedu_username && loginInfoObj.minedu_username.length > 0 && loginInfoObj.auth_role === MINISTRY_ROLE )
) {
resolve(true);
}
else {
resolve(false);
}
return loginInfoObj;
}, {});
} else
resolve(false);
},
error => {
console.log("Error Getting Auth Data");
reject("Error Getting Auth Data");
});
});
}
isLoggedInForReports(role1, role2, role3) {
return new Promise<boolean>((resolve, reject) => {
this._ngRedux.select("loginInfo")
......@@ -200,6 +229,34 @@ export class AuthService {
});
}
isGelStudentsLockedforTworoles(role1,role2) {
return new Promise<boolean>((resolve, reject) => {
this._ngRedux.select("loginInfo")
.map(loginInfo => <ILoginInfoRecords>loginInfo)
.subscribe(loginInfo => {
if (loginInfo.size > 0) {
loginInfo.reduce(({}, loginInfoObj) => {
if ((loginInfoObj.lock_students_gel && loginInfoObj.lock_students_gel === 1 && (loginInfoObj.auth_role === role1 || loginInfoObj.auth_role === role2)))
{
resolve(true);
}
else {
resolve(false);
}
return loginInfoObj;
}, {});
} else
resolve(false);
},
error => {
console.log("Error Getting Auth Data");
reject("Error Getting Auth Data");
});
});
}
isCapacityLocked(role) {
return new Promise<boolean>((resolve, reject) => {
this._ngRedux.select("loginInfo")
......
......@@ -7,7 +7,7 @@ import { CookieService } from "ngx-cookie";
import { BehaviorSubject, Subscription } from "rxjs/Rx";
import { AppSettings } from "../app.settings";
import { DIDE_ROLE, MINISTRY_ROLE, PDE_ROLE, SCHOOL_ROLE, SCHOOLGEL_ROLE, SCHOOLGYM_ROLE } from "../constants";
import { DIDE_ROLE, MINISTRY_ROLE, PDE_ROLE, SCHOOL_ROLE, SCHOOLGEL_ROLE, SCHOOLGYM_ROLE ,SCHOOLGYMLT_ROLE } from "../constants";
import { LOGININFO_INITIAL_STATE } from "../store/logininfo/logininfo.initial-state";
import { ILoginInfoRecords } from "../store/logininfo/logininfo.types";
import { IRRegionSchool } from "../store/regionschools/regionschools.types";
......@@ -428,7 +428,7 @@ export class HelperDataService implements OnInit, OnDestroy {
} else {
this.createAuthorizationHeader(headers);
}
if (this.authRole === SCHOOL_ROLE || this.authRole === SCHOOLGEL_ROLE || this.authRole === PDE_ROLE || this.authRole === DIDE_ROLE || this.authRole === SCHOOLGYM_ROLE) {
if (this.authRole === SCHOOL_ROLE || this.authRole === SCHOOLGEL_ROLE || this.authRole === PDE_ROLE || this.authRole === DIDE_ROLE || this.authRole === SCHOOLGYM_ROLE || this.authRole === SCHOOLGYMLT_ROLE) {
logoutRoute = "/cas/logout";
} else if (this.authRole === MINISTRY_ROLE) {
logoutRoute = "/ministry/logout";
......
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 to comment