added fields to EpalStudent. Added extra fields to logininfo

parent 39a16b4d
......@@ -50,12 +50,30 @@ class CurrentUser extends ControllerBase
], Response::HTTP_FORBIDDEN);
}
$epalConfigs = $this->entityTypeManager->getStorage('epal_config')->loadByProperties(array('name' => 'epal_config'));
$epalConfig = reset($epalConfigs);
if (!$epalConfig) {
return $this->respondWithStatus([
'message' => t("Configuration not found"),
], Response::HTTP_FORBIDDEN);
}
$userRoles = $user->getRoles();
foreach ($userRoles as $userRole) {
if (($userRole === 'epal') || ($userRole === 'regioneduadmin') || ($userRole === 'eduadmin')) {
return $this->respondWithStatus([
'name' => $user->mail->value,
'title' => $user->init->value,
'cu_name' => $user->mail->value,
'cu_surname' => mb_substr($epalUser->surname->value,0,4,'UTF-8') !== "####" ? $epalUser->surname->value : '',
'cu_fathername' => mb_substr($epalUser->fathername->value,0,4,'UTF-8') !== "####" ? $epalUser->fathername->value : '',
'cu_mothername' => mb_substr($epalUser->mothername->value,0,4,'UTF-8') !== "####" ? $epalUser->mothername->value : '',
'cu_email' => mb_substr($user->mail->value,0,4,'UTF-8') !== "####" ? $user->mail->value : '',
'minedu_username' => '',
'minedu_userpassword' => '',
'lock_capacity' => $epalConfig->lock_school_capacity->value,
'lock_students' => $epalConfig->lock_school_students_view->value,
'lock_application' => $epalConfig->lock_application->value,
'disclaimer_checked' => "0",
'title' => $user->init->value
], Response::HTTP_OK);
} else if ($userRole === 'applicant') {
break;
......@@ -66,8 +84,24 @@ class CurrentUser extends ControllerBase
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers);
if ($epalUser) {
$userName = $epalUser->name->value;
$userSurname = $epalUser->surname->value;
$userFathername = $epalUser->fathername->value;
$userMothername = $epalUser->mothername->value;
$userEmail = $user->mail->value;
return $this->respondWithStatus([
'name' => $epalUser->name->value,
'cu_name' => mb_substr($epalUser->name->value,0,4,'UTF-8') !== "####" ? $epalUser->name->value : '',
'cu_surname' => mb_substr($epalUser->surname->value,0,4,'UTF-8') !== "####" ? $epalUser->surname->value : '',
'cu_fathername' => mb_substr($epalUser->fathername->value,0,4,'UTF-8') !== "####" ? $epalUser->fathername->value : '',
'cu_mothername' => mb_substr($epalUser->mothername->value,0,4,'UTF-8') !== "####" ? $epalUser->mothername->value : '',
'cu_email' => mb_substr($user->mail->value,0,4,'UTF-8') !== "####" ? $user->mail->value : '',
'minedu_username' => '',
'minedu_userpassword' => '',
'lock_capacity' => $epalConfig->lock_school_capacity->value,
'lock_students' => $epalConfig->lock_school_students_view->value,
'lock_application' => $epalConfig->lock_application->value,
'disclaimer_checked' => "0",
'verificationCodeVerified' => $epalUser->verificationcodeverified->value,
], Response::HTTP_OK);
} else {
return $this->respondWithStatus([
......
......@@ -206,7 +206,7 @@ class EpalConfig extends ContentEntityBase implements EpalConfigInterface {
->setSettings(array(
'text_processing' => 0,
))
->setRequired(TRUE)
->setRequired(FALSE)
->setDefaultValue(FALSE)
->setDisplayOptions('view', array(
'label' => 'above',
......@@ -226,7 +226,7 @@ class EpalConfig extends ContentEntityBase implements EpalConfigInterface {
->setSettings(array(
'text_processing' => 0,
))
->setRequired(TRUE)
->setRequired(FALSE)
->setDefaultValue(FALSE)
->setDisplayOptions('view', array(
'label' => 'above',
......@@ -246,7 +246,7 @@ class EpalConfig extends ContentEntityBase implements EpalConfigInterface {
->setSettings(array(
'text_processing' => 0,
))
->setRequired(TRUE)
->setRequired(FALSE)
->setDefaultValue(FALSE)
->setDisplayOptions('view', array(
'label' => 'above',
......
......@@ -505,7 +505,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
->setLabel(t('Ημερομηνία γέννησης μαθητή'))
->setDescription(t('Δώσε την Ημερομηνία γέννησης μαθητή.'))
->setSetting('datetime_type', 'date')
->setRequired(false)
->setRequired(true)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
......@@ -543,7 +543,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
'max_length' => 50,
'text_processing' => 0,
))
->setRequired(false)
->setRequired(true)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
......@@ -564,7 +564,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
'max_length' => 50,
'text_processing' => 0,
))
->setRequired(false)
->setRequired(true)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
......@@ -585,7 +585,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
'max_length' => 50,
'text_processing' => 0,
))
->setRequired(false)
->setRequired(true)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
......@@ -606,7 +606,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
'max_length' => 50,
'text_processing' => 0,
))
->setRequired(false)
->setRequired(true)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
......@@ -627,6 +627,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
'max_length' => 20,
'text_processing' => 0,
))
->setRequired(false)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
......@@ -647,6 +648,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
'max_length' => 100,
'text_processing' => 0,
))
->setRequired(true)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
......@@ -667,27 +669,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
'max_length' => 10,
'text_processing' => 0,
))
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'string_textfield',
'weight' => -4,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['regionarea'] = BaseFieldDefinition::create('string')
->setLabel(t('Πόλη-Κοινότητα'))
->setDescription(t('Δώσε την πόλη ή κοινότητα που διαμένεις.'))
->setSettings(array(
'max_length' => 100,
'text_processing' => 0,
))
->setDefaultValue('')
->setRequired(true)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
......@@ -707,6 +689,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
'max_length' => 100,
'text_processing' => 0,
))
->setRequired(true)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
......@@ -727,6 +710,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
'max_length' => 50,
'text_processing' => 0,
))
->setRequired(true)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
......@@ -747,6 +731,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
'max_length' => 10,
'text_processing' => 0,
))
->setRequired(false)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
......@@ -912,6 +897,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
'max_length' => 50,
'text_processing' => 0,
))
->setRequired(true)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
......@@ -932,6 +918,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
'max_length' => 50,
'text_processing' => 0,
))
->setRequired(true)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
......@@ -969,7 +956,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
->setSettings(array(
'text_processing' => 0,
))
->setRequired(false)
->setRequired(true)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'boolean',
......@@ -982,6 +969,90 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['guardian_name'] = BaseFieldDefinition::create('string')
->setLabel(t('Όνομα κηδεμόνα'))
->setDescription(t('Δώσε το όνομα κηδεμόνα.'))
->setSettings(array(
'max_length' => 50,
'text_processing' => 0,
))
->setRequired(true)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'string_textfield',
'weight' => -4,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['guardian_surname'] = BaseFieldDefinition::create('string')
->setLabel(t('Επώνυμο κηδεμόνα'))
->setDescription(t('Δώσε το επώνυμο κηδεμόνα.'))
->setSettings(array(
'max_length' => 50,
'text_processing' => 0,
))
->setRequired(true)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'string_textfield',
'weight' => -4,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['guardian_fathername'] = BaseFieldDefinition::create('string')
->setLabel(t('Όνομα πατέρα κηδεμόνα'))
->setDescription(t('Δώσε το όνομα πατέρα του κηδεμόνα.'))
->setSettings(array(
'max_length' => 50,
'text_processing' => 0,
))
->setRequired(true)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'string_textfield',
'weight' => -4,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['guardian_mothername'] = BaseFieldDefinition::create('string')
->setLabel(t('Όνομα μητέρας κηδεμόνα'))
->setDescription(t('Δώσε το όνομα μητέρας του κηδεμόνα.'))
->setSettings(array(
'max_length' => 50,
'text_processing' => 0,
))
->setRequired(true)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'string_textfield',
'weight' => -4,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status'))
->setDescription(t('A boolean indicating whether the EPAL Student is published.'))
......
......@@ -116,8 +116,7 @@ export default class MinistryHome implements OnInit {
if (success) {
this.authRole = 'supervisor';
this._hds.setMineduCurrentUser(this.userDataGroup.value['minedu_username'], this.userDataGroup.value['minedu_userpassword'], this.authRole);
console.log("MPHKA");
//this.validLogin = true;
this.validLogin = 1;
this.userDataGroup.value['cu_name'] = this.userDataGroup.value['minedu_username'];
this.userDataGroup.value['auth_role'] = 'supervisor';
......
......@@ -283,15 +283,7 @@ export class HelperDataService implements OnInit, OnDestroy {
this.authRole = loginInfoToken.auth_role;
});
let headers = new Headers({
//"Authorization": "Basic cmVzdHVzZXI6czNjckV0MFAwdWwwJA==", // encoded user:pass
// "Authorization": "Basic bmthdHNhb3Vub3M6emVtcmFpbWU=",
"Content-Type": "application/json",
// "Content-Type": "text/plain", // try to skip preflight
//"X-CSRF-Token": "hVtACDJjFRSyE4bgGJENHbXY0B9yNhF71Fw-cYHSDNY"
//"X-CSRF-Token": "fj1QtF_Z_p6kE19EdCnN08zoSjVfcT4Up-ciW6I0IG8"
"X-CSRF-Token": "LU92FaWYfImfZxfldkF5eVnssdHoV7Aa9fg8K1bWYUc",
// "X-oauth-enabled": "true",
// "X-Auth-Token": this.authToken
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
......@@ -383,21 +375,9 @@ export class HelperDataService implements OnInit, OnDestroy {
this.authToken = oauthtoken;
this.authRole = oauthrole;
//console.log("MIPOS");
let headers = new Headers({
// "Authorization": "Basic " + btoa(this.authToken + ':' + this.authToken),
// "Authorization": "Basic cmVzdHVzZXI6czNjckV0MFAwdWwwJA==", // encoded user:pass
// "Authorization": "Basic bmthdHNhb3Vub3M6emVtcmFpbWU=",
// "Authorization": "Basic " + "aGFyaXNwOmhhcmlzcGFzcw==",
"Content-Type": "application/json",
"Access-Control-Allow-Credentials": "true",
// "Content-Type": "text/plain", // try to skip preflight
//"X-CSRF-Token": "hVtACDJjFRSyE4bgGJENHbXY0B9yNhF71Fw-cYHSDNY"
//"X-CSRF-Token": "fj1QtF_Z_p6kE19EdCnN08zoSjVfcT4Up-ciW6I0IG8"
// "X-CSRF-Token": "LU92FaWYfImfZxfldkF5eVnssdHoV7Aa9fg8K1bWYUc",
// "X-oauth-enabled": "true",
// "X-Auth-Token": this.authToken
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
......@@ -425,7 +405,21 @@ export class HelperDataService implements OnInit, OnDestroy {
transformUserSchema(userlogin: any, oauthtoken: string, oauthrole: string) {
let rsa = Array<ILoginInfoToken>();
rsa.push(<ILoginInfoToken>{ 'auth_token': oauthtoken, 'auth_role': oauthrole, 'cu_name': userlogin.name });
rsa.push(<ILoginInfoToken>{
'auth_token': oauthtoken,
'auth_role': oauthrole,
'cu_name': userlogin.cu_name,
'cu_surname': userlogin.cu_surname,
'cu_fathername': userlogin.cu_fathername,
'cu_mothername': userlogin.cu_mothername,
'cu_email': userlogin.cu_email,
'minedu_username': userlogin.minedu_username,
'minedu_userpassword': userlogin.minedu_userpassword,
'lock_capacity': parseInt(userlogin.lock_capacity),
'lock_students': parseInt(userlogin.lock_students),
'lock_application': parseInt(userlogin.lock_application),
'disclaimer_checked': parseInt(userlogin.disclaimer_checked)
});
return rsa;
}
......@@ -450,20 +444,6 @@ export class HelperDataService implements OnInit, OnDestroy {
let logoutRoute = '/oauth/logout';
if (this.authRole === SCHOOL_ROLE || this.authRole === PDE_ROLE || this.authRole === DIDE_ROLE) {
logoutRoute = '/cas/logout';
return new Promise((resolve, reject) => {
this.http.get(`${AppSettings.API_ENDPOINT}${logoutRoute}${AppSettings.API_ENDPOINT_PARAMS}`, options)
.map(response => response)
.subscribe(data => {
this._cookieService.removeAll();
resolve(data);
}, // put the data returned from the server in our variable
error => {
console.log("Error Logout"); // in case of failure show this message
reject("Error Logout");
},
() => console.log("Logging out"));//run this code in all cases); */
});
}
else if (this.authRole === MINISTRY_ROLE)
logoutRoute = '/ministry/logout';
......
......@@ -13,8 +13,21 @@ export function loginInfoReducer(state: ILoginInfo = LOGININFO_INITIAL_STATE, ac
let loginInfoTokens = Array<ILoginInfoToken>();
let i=0;
action.payload.loginInfos.forEach(loginInfo => {
loginInfoTokens.push(<ILoginInfoToken>{auth_token: loginInfo.auth_token, auth_role: loginInfo.auth_role, cu_name: loginInfo.cu_name,
minedu_username: loginInfo.minedu_username, minedu_userpassword: loginInfo.minedu_userpassword});
loginInfoTokens.push(<ILoginInfoToken>{
auth_token: loginInfo.auth_token,
auth_role: loginInfo.auth_role,
cu_name: loginInfo.cu_name,
cu_surname: loginInfo.cu_surname,
cu_fathername: loginInfo.cu_fathername,
cu_mothername: loginInfo.cu_mothername,
cu_email: loginInfo.cu_email,
minedu_username: loginInfo.minedu_username,
minedu_userpassword: loginInfo.minedu_userpassword,
lock_capacity: loginInfo.lock_capacity,
lock_students: loginInfo.lock_students,
lock_application: loginInfo.lock_application,
disclaimer_checked: loginInfo.disclaimer_checked
});
i++;
});
return Seq(loginInfoTokens).map(n => n).toList();
......
......@@ -3,8 +3,21 @@ import { ILoginInfo, ILoginInfoToken } from './logininfo.types';
export function deimmutifyLoginInfo(state: ILoginInfo): ILoginInfoToken[] {
let fetchedLoginInfoTokens = new Array();
state.forEach(loginInfoToken => {
fetchedLoginInfoTokens.push(<ILoginInfoToken>{auth_token: loginInfoToken.auth_token, auth_role: loginInfoToken.auth_role, cu_name: loginInfoToken.cu_name,
minedu_username: loginInfoToken.minedu_username, minedu_userpassword: loginInfoToken.minedu_userpassword});
fetchedLoginInfoTokens.push(<ILoginInfoToken>{
auth_token: loginInfoToken.auth_token,
auth_role: loginInfoToken.auth_role,
cu_name: loginInfoToken.cu_name,
cu_surname: loginInfoToken.cu_surname,
cu_fathername: loginInfoToken.cu_fathername,
cu_mothername: loginInfoToken.cu_mothername,
cu_email: loginInfoToken.cu_email,
minedu_username: loginInfoToken.minedu_username,
minedu_userpassword: loginInfoToken.minedu_userpassword,
lock_capacity: loginInfoToken.lock_capacity,
lock_students: loginInfoToken.lock_students,
lock_application: loginInfoToken.lock_application,
disclaimer_checked: loginInfoToken.disclaimer_checked
});
});
return fetchedLoginInfoTokens;
};
......@@ -4,8 +4,16 @@ export interface ILoginInfoToken {
auth_token: string;
auth_role: string;
cu_name: string;
cu_surname: string;
cu_fathername: string;
cu_mothername: string;
cu_email: string;
minedu_username: string;
minedu_userpassword: string;
lock_capacity: number;
lock_students: number;
lock_application: number;
disclaimer_checked: number;
}
export type ILoginInfo = List<ILoginInfoToken>;
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