Commit adc40507 authored by Νίκος Κατσαούνος's avatar Νίκος Κατσαούνος

Merge branch 'develop' of https://git.minedu.gov.gr/itminedu/e-epal into component_updates

parents b04869ce ecf690c8
......@@ -91,9 +91,9 @@ class CASLogin extends ControllerBase
$this->allowed2 = $CASOSTConfig->allowed2->value;
$this->allowed2Value = $CASOSTConfig->allowed2value->value;
}
// phpCAS::setDebug("/home/haris/devel/eepal/drupal/modules/casost/phpcas.log");
phpCAS::setDebug("/home/haris/devel/eepal/drupal/modules/casost/phpcas.log");
// Enable verbose error messages. Disable in production!
// phpCAS::setVerbose(true);
phpCAS::setVerbose(true);
phpCAS::client($this->serverVersion,
$this->serverHostname,
......@@ -124,6 +124,10 @@ class CASLogin extends ControllerBase
return $response;
}
$attributes = phpCAS::getAttributes();
/* foreach ($attributes as $attr_key => $attr_value) {
$this->logger->warning($attr_key);
$this->logger->warning(phpCAS::getAttribute($attr_key));
} */
/* $isAllowed = true;
$att1 = $attributes[$this->allowed1];
......@@ -166,28 +170,44 @@ class CASLogin extends ControllerBase
$filterAttribute = function ($attribute) use ($attributes) {
if (!isset($attributes[$attribute])) {
return;
}
if (is_array($attributes[$attribute])) {
return $attributes[$attribute];
return false;
}
return $attributes[$attribute];
};
$exposedRole = 'director';
$internalRole = 'epal';
$CASTitle = preg_replace('/\s+/', '', $filterAttribute('title'));
if ($CASTitle === 'ΠΕΡΙΦΕΡΕΙΑΚΗΔΙΕΥΘΥΝΣΗΕΚΠΑΙΔΕΥΣΗΣ-ΠΔΕ') {
$exposedRole = 'pde';
$internalRole = 'regioneduadmin';
} else if ($CASTitle === 'ΔΙΕΥΘΥΝΣΗΔΕ-ΔIΔΕ') {
$exposedRole = 'dide';
$internalRole = 'eduadmin';
} else if ($CASTitle === 'ΕΠΑΛ') {
$exposedRole = 'director';
$internalRole = 'epal';
} else {
$response = new Response();
$this->logger->warning(t('Access is allowed only to official school accounts or administration'));
$response->setContent(t('Access is allowed only to official school accounts or administration'));
$response->setStatusCode(Response::HTTP_FORBIDDEN);
$response->headers->set('Content-Type', 'application/json;charset=UTF-8');
return $response;
}
// $this->logger->warning('cn=' . $filterAttribute('cn'));
$epalToken = $this->authenticatePhase2($request, $CASUser, $filterAttribute('cn'));
$epalToken = $this->authenticatePhase2($request, $CASUser, $internalRole, $filterAttribute('cn'));
if ($epalToken) {
$cookie = new Cookie('auth_token', $epalToken, 0, '/', null, false, false);
$cookie2 = new Cookie('auth_role', 'director', 0, '/', null, false, false);
$cookie2 = new Cookie('auth_role', $exposedRole, 0, '/', null, false, false);
return new RedirectResponseWithCookie($this->redirectUrl, 302, array ($cookie, $cookie2));
// $headers = array("auth_token" => $epalToken, "auth_role" => "director");
// return new RedirectResponse($this->redirectUrl, 302, $headers);
} else {
$response = new Response();
$response->setContent('forbidden');
$response->setContent('No proper authentication');
$response->setStatusCode(Response::HTTP_FORBIDDEN);
$response->headers->set('Content-Type', 'application/json');
return $response;
......@@ -196,14 +216,14 @@ class CASLogin extends ControllerBase
} catch (\Exception $e) {
$this->logger->warning($e->getMessage());
$response = new Response();
$response->setContent('forbidden');
$response->setContent('Unexpected Problem');
$response->setStatusCode(Response::HTTP_FORBIDDEN);
$response->headers->set('Content-Type', 'application/json');
return $response;
}
}
public function authenticatePhase2($request, $CASUser, $cn)
public function authenticatePhase2($request, $CASUser, $internalRole, $cn)
{
$trx = $this->connection->startTransaction();
try {
......@@ -241,7 +261,7 @@ class CASLogin extends ControllerBase
$user->set('preferred_admin_langcode', $language_interface->getId());
//Adding default user role
$user->addRole('epal');
$user->addRole($internalRole);
$user->save();
}
......
......@@ -110,6 +110,7 @@ class CASLogout extends ControllerBase
if (!$user) {
$this->logger->warning("user not found");
$response = new Response();
$response->setContent('forbidden');
$response->setStatusCode(Response::HTTP_FORBIDDEN);
......
langcode: el
status: true
dependencies: { }
id: eduadmin
label: eduadmin
weight: 5
is_admin: null
permissions:
- 'view published epal student class entities'
- 'view published epal student entities'
- 'view published epal class limits entities'
- 'view published epal criteria entities'
- 'view published epal student course field entities'
- 'view published epal student epal chosen entities'
- 'view published epal student moria entities'
- 'view published epal student sector field entities'
- 'view published epal users entities'
- 'view unpublished epal student class entities'
- 'view unpublished epal student entities'
- 'view unpublished epal class limits entities'
- 'view unpublished epal criteria entities'
- 'view unpublished epal student course field entities'
- 'view unpublished epal student epal chosen entities'
- 'view unpublished epal student moria entities'
- 'view unpublished epal student sector field entities'
- 'view unpublished epal users entities'
- 'view published eepal admin area entities'
- 'view published eepal prefecture entities'
- 'view published eepal region entities'
- 'view published eepal school entities'
- 'view published eepal sectors entities'
- 'view published eepal sectors in epal entities'
- 'view published eepal specialties in epal entities'
- 'view published eepal specialty entities'
- 'view unpublished eepal admin area entities'
- 'view unpublished eepal prefecture entities'
- 'view unpublished eepal region entities'
- 'view unpublished eepal school entities'
- 'view unpublished eepal sectors entities'
- 'view unpublished eepal sectors in epal entities'
- 'view unpublished eepal specialties in epal entities'
- 'view unpublished eepal specialty entities'
langcode: el
status: true
dependencies: { }
id: regioneduadmin
label: regioneduadmin
weight: 6
is_admin: null
permissions:
- 'view published epal student class entities'
- 'view published epal student entities'
- 'view published epal class limits entities'
- 'view published epal criteria entities'
- 'view published epal student course field entities'
- 'view published epal student epal chosen entities'
- 'view published epal student moria entities'
- 'view published epal student sector field entities'
- 'view published epal users entities'
- 'view unpublished epal student class entities'
- 'view unpublished epal student entities'
- 'view unpublished epal class limits entities'
- 'view unpublished epal criteria entities'
- 'view unpublished epal student course field entities'
- 'view unpublished epal student epal chosen entities'
- 'view unpublished epal student moria entities'
- 'view unpublished epal student sector field entities'
- 'view unpublished epal users entities'
- 'view published eepal admin area entities'
- 'view published eepal prefecture entities'
- 'view published eepal region entities'
- 'view published eepal school entities'
- 'view published eepal sectors entities'
- 'view published eepal sectors in epal entities'
- 'view published eepal specialties in epal entities'
- 'view published eepal specialty entities'
- 'view unpublished eepal admin area entities'
- 'view unpublished eepal prefecture entities'
- 'view unpublished eepal region entities'
- 'view unpublished eepal school entities'
- 'view unpublished eepal sectors entities'
- 'view unpublished eepal sectors in epal entities'
- 'view unpublished eepal specialties in epal entities'
- 'view unpublished eepal specialty entities'
import { CRITERIA_RECEIVED, CRITERIA_SAVE} from '../constants';
import { CRITERIA_RECEIVED, CRITERIA_SAVE, CRITERIA_INIT } from '../constants';
import { Injectable } from '@angular/core';
import { NgRedux } from 'ng2-redux';
import { IAppState } from '../store';
......@@ -34,4 +34,12 @@ export class CriteriaActions {
});
};
initCriteria = () => {
return this._ngRedux.dispatch({
type: CRITERIA_INIT,
payload: {
}
});
};
}
import { EPALCLASSES_SAVE } from '../constants';
import { EPALCLASSES_INIT } from '../constants';
import { Injectable } from '@angular/core';
import { NgRedux } from 'ng2-redux';
import { IAppState } from '../store';
......@@ -19,9 +20,12 @@ export class EpalClassesActions {
});
};
}
initEpalClasses = () => {
return this._ngRedux.dispatch({
type: EPALCLASSES_INIT,
payload: {
}
});
};
}
import { STUDENTDATAFIELDS_SAVE, STUDENTDATAFIELDS_RECEIVED } from '../constants';
import { STUDENTDATAFIELDS_SAVE, STUDENTDATAFIELDS_INIT } from '../constants';
import { Injectable } from '@angular/core';
import { NgRedux } from 'ng2-redux';
import { IAppState } from '../store';
......@@ -22,4 +22,12 @@ export class StudentDataFieldsActions {
};
initStudentDataFields = () => {
return this._ngRedux.dispatch({
type: STUDENTDATAFIELDS_INIT,
payload: {
}
});
};
}
export const API_ENDPOINT = 'http://eduslim2.minedu.gov.gr/drupal-8.2.6';
export const API_ENDPOINT = 'http://eduslim2.minedu.gov.gr/drupal';
// export const API_ENDPOINT = 'http://eduslim2.minedu.gov.gr/angular/eepal-front/drupal';
export class AppSettings {
public static get API_ENDPOINT(): string {
return 'http://eduslim2.minedu.gov.gr/drupal-8.2.6';
return 'http://eduslim2.minedu.gov.gr/drupal';
// return 'http://eduslim2.minedu.gov.gr/angular/eepal-front/drupal';
}
}
......@@ -7,6 +7,7 @@ import { Observable } from 'rxjs/Rx';
import { IAppState } from '../store/store';
import { HelperDataService } from '../services/helper-data-service';
import { CookieService } from 'ngx-cookie';
import { STUDENT_ROLE } from '../constants';
import {
FormBuilder,
FormGroup,
......@@ -74,7 +75,7 @@ export default class Home implements OnInit {
state.loginInfo.reduce(({}, loginInfoToken) => {
this.authToken = loginInfoToken.auth_token;
this.authRole = loginInfoToken.auth_role;
if (this.authToken && this.authToken.length > 0 && this.authRole && this.authRole === 'student')
if (this.authToken && this.authToken.length > 0 && this.authRole && this.authRole === STUDENT_ROLE)
this.router.navigate(['/parent-form']);
return loginInfoToken;
}, {});
......
......@@ -15,7 +15,7 @@
  
<button type="button" class="btn-primary btn-sm pull-right" (click)="oauthSignOut()">
<button type="button" class="btn-primary btn-sm pull-right" (click)="signOut()">
<i class="fa fa-sign-out"></i>
</button>
</div>
......
......@@ -9,8 +9,13 @@ import { ILoginInfo, ILoginInfoToken } from '../../store/logininfo/logininfo.typ
import { HelperDataService } from '../../services/helper-data-service';
import { LoginInfoActions } from '../../actions/logininfo.actions';
import { LOGININFO_INITIAL_STATE } from '../../store/logininfo/logininfo.initial-state';
import { SCHOOL_ROLE, STUDENT_ROLE, PDE_ROLE, DIDE_ROLE, MINISTRY_ROLE } from '../../constants';
import { EpalClassesActions } from '../../actions/epalclass.actions';
import { SectorFieldsActions } from '../../actions/sectorfields.actions';
import { RegionSchoolsActions } from '../../actions/regionschools.actions';
import { SectorCoursesActions } from '../../actions/sectorcourses.actions';
import { CriteriaActions } from '../../actions/criteria.actions';
import { StudentDataFieldsActions } from '../../actions/studentdatafields.actions';
@Component({
selector: 'reg-navbar',
......@@ -26,6 +31,12 @@ import { LOGININFO_INITIAL_STATE } from '../../store/logininfo/logininfo.initial
constructor( private _ata: LoginInfoActions,
private _hds: HelperDataService,
private _csa: SectorCoursesActions,
private _sfa: SectorFieldsActions,
private _rsa: RegionSchoolsActions,
private _eca: EpalClassesActions,
private _sdfa: StudentDataFieldsActions,
private _cria: CriteriaActions,
private _ngRedux: NgRedux<IAppState>,
private router: Router
) {
......@@ -58,16 +69,28 @@ import { LOGININFO_INITIAL_STATE } from '../../store/logininfo/logininfo.initial
}
oauthSignOut() {
signOut() {
this._hds.signOut().then(data => {
this._ata.initLoginInfo();
if (this.authRole === 'director') {
if (this.authRole === SCHOOL_ROLE) {
this.router.navigate(['/school']);
}
else if (this.authRole === PDE_ROLE) {
this.router.navigate(['/school']);
}
else if (this.authRole === DIDE_ROLE) {
this.router.navigate(['/school']);
}
else if (this.authRole === 'student') {
else if (this.authRole === STUDENT_ROLE) {
this._eca.initEpalClasses();
this._sfa.initSectorFields();
this._rsa.initRegionSchools();
this._csa.initSectorCourses();
this._sdfa.initStudentDataFields();
this._cria.initCriteria();
this.router.navigate(['']);
}
else if (this.authRole === 'supervisor') {
else if (this.authRole === MINISTRY_ROLE) {
this.router.navigate(['/ministry']);
}
this.authToken = '';
......
......@@ -106,15 +106,6 @@ import {AppSettings} from '../../app.settings';
this._sfa.initSectorFields();
this._rsa.initRegionSchools();
this._csa.initSectorCourses();
/* this._sfa.getSectorFields(true);
this._rsa.getRegionSchools(1,"-1", true);
console.log("Here I am!");
//this._rsa.saveRegionSchoolsOrder(true);
this._csa.getSectorCourses(true);
this._csa.getSectorCourses(true); */
}
}
......@@ -14,10 +14,11 @@ export const SECTORCOURSES_RECEIVED = 'SECTORCOURSES_RECEIVED';
export const SECTORCOURSES_SELECTED_SAVE = 'SECTORCOURSES_SELECTED_SAVE';
export const SECTORCOURSES_INIT = 'SECTORCOURSES_INIT';
export const STUDENTDATAFIELDS_RECEIVED = 'STUDENTDATAFIELDS_RECEIVED';
export const STUDENTDATAFIELDS_SAVE = 'STUDENTDATAFIELDS_SAVE';
export const STUDENTDATAFIELDS_INIT = 'STUDENTDATAFIELDS_INIT';
export const EPALCLASSES_SAVE = 'EPALCLASSES_SAVE';
export const EPALCLASSES_INIT = 'EPALCLASSES_INIT';
export const LOGININFO_SAVE = 'LOGININFO_SAVE';
......@@ -30,6 +31,7 @@ export const LOGININFO_INIT = 'LOGININFO_INIT';
export const CRITERIA_RECEIVED = 'CRITERIA_RECEIVED';
export const CRITERIA_SAVE = 'CRITERIA_SAVE';
export const CRITERIA_INIT = 'CRITERIA_INIT';
//export const VALID_NAMES_PATTERN = '[Α-ΩΆΈΉΊΎΌΏα-ωάέήίύόώ ]*$';
export const VALID_NAMES_PATTERN = '[A-Za-zΑ-ΩΆΈΉΊΎΌΏα-ωάέήίύόώ ]*$';
......@@ -50,3 +52,6 @@ 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 STUDENT_ROLE = 'student';
export const PDE_ROLE = 'pde';
export const DIDE_ROLE = 'dide';
export const MINISTRY_ROLE = 'supervisor';
......@@ -34,7 +34,7 @@ export class AuthService {
resolve(false);
},
error => {
console.log("Error Sending Verification Code");
console.log("Error Getting Auth Data");
reject("Error Getting Auth Data");
},
() => console.log("Getting Auth Data"));
......
......@@ -12,7 +12,7 @@ import { NgRedux, select } from 'ng2-redux';
import { IAppState } from '../store/store';
import { ILoginInfo, ILoginInfoToken } from '../store/logininfo/logininfo.types';
import { LOGININFO_INITIAL_STATE } from '../store/logininfo/logininfo.initial-state';
import { SCHOOL_ROLE, STUDENT_ROLE, PDE_ROLE, DIDE_ROLE, MINISTRY_ROLE } from '../constants';
const HEADER = { headers: new Headers({ 'Content-Type': 'application/json' }) };
......@@ -428,15 +428,15 @@ export class HelperDataService implements OnInit, OnDestroy {
// "X-Auth-Token": this.authToken
});
if (this.authRole === "supervisor")
if (this.authRole === MINISTRY_ROLE)
this.createMinistryAuthorizationHeader(headers, this.minedu_userName, this.minedu_userPassword);
else
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers, withCredentials: true });
let logoutRoute = '/oauth/logout';
if (this.authRole === 'director')
if (this.authRole === SCHOOL_ROLE || this.authRole === PDE_ROLE || this.authRole === DIDE_ROLE)
logoutRoute = '/cas/logout';
else if (this.authRole === 'supervisor')
else if (this.authRole === MINISTRY_ROLE)
logoutRoute = '/ministry/logout';
return new Promise((resolve, reject) => {
......
......@@ -4,7 +4,8 @@ import { Seq } from 'immutable';
import {
CRITERIA_RECEIVED,
CRITERIA_SAVE
CRITERIA_SAVE,
CRITERIA_INIT
} from '../../constants';
export function criteriaReducer(state: ICriter = CRITERIA_INITIAL_STATE, action): ICriter {
......@@ -29,6 +30,8 @@ export function criteriaReducer(state: ICriter = CRITERIA_INITIAL_STATE, action)
});
return Seq(criter).map(n => n).toList();
case CRITERIA_INIT:
return CRITERIA_INITIAL_STATE;
default: return state;
}
};
......
......@@ -2,7 +2,7 @@ import { IEpalClasses, IEpalClass } from './epalclasses.types';
import { EPALCLASSES_INITIAL_STATE } from './epalclasses.initial-state';
import { Seq } from 'immutable';
import { EPALCLASSES_SAVE} from '../../constants';
import { EPALCLASSES_SAVE, EPALCLASSES_INIT } from '../../constants';
export function epalclassesReducer(state: IEpalClasses = EPALCLASSES_INITIAL_STATE, action): IEpalClasses {
......@@ -12,11 +12,10 @@ export function epalclassesReducer(state: IEpalClasses = EPALCLASSES_INITIAL_STA
case EPALCLASSES_SAVE:
let selectedEpalClasses = Array<IEpalClass>();
selectedEpalClasses.push(<IEpalClass>{ name: action.payload.epalClasses.name});
return Seq(selectedEpalClasses).map(n => n).toList();
case EPALCLASSES_INIT:
return EPALCLASSES_INITIAL_STATE;
default: return state;
}
};
import { IStudentDataFields, IStudentDataField } from './studentdatafields.types';
import { STUDENT_DATA_FIELDS_INITIAL_STATE } from './studentdatafields.initial-state';
import { Seq } from 'immutable';
import {
STUDENTDATAFIELDS_RECEIVED,
STUDENTDATAFIELDS_SAVE
} from '../../constants';
import { STUDENTDATAFIELDS_SAVE, STUDENTDATAFIELDS_INIT } from '../../constants';
export function studentDataFieldsReducer(state: IStudentDataFields = STUDENT_DATA_FIELDS_INITIAL_STATE, action): IStudentDataFields {
switch (action.type) {
......@@ -19,6 +15,8 @@ export function studentDataFieldsReducer(state: IStudentDataFields = STUDENT_DAT
});
return Seq(studentDataFields).map(n => n).toList();
case STUDENTDATAFIELDS_INIT:
return STUDENT_DATA_FIELDS_INITIAL_STATE;
default: return state;
}
};
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