WIP: Fixing user locking problem through flood system

parent df99a4d1
...@@ -94,7 +94,7 @@ class CASLogin extends ControllerBase ...@@ -94,7 +94,7 @@ class CASLogin extends ControllerBase
$this->allowed2 = $CASOSTConfig->allowed2->value; $this->allowed2 = $CASOSTConfig->allowed2->value;
$this->allowed2Value = $CASOSTConfig->allowed2value->value; $this->allowed2Value = $CASOSTConfig->allowed2value->value;
} }
phpCAS::setDebug("/home/haris/devel/eepal/drupal/modules/casost/phpcas.log"); phpCAS::setDebug("phpcas.log");
// Enable verbose error messages. Disable in production! // Enable verbose error messages. Disable in production!
phpCAS::setVerbose(true); phpCAS::setVerbose(true);
...@@ -199,16 +199,16 @@ class CASLogin extends ControllerBase ...@@ -199,16 +199,16 @@ class CASLogin extends ControllerBase
return $response; return $response;
} }
// $this->logger->warning('cn=' . $filterAttribute('cn')); // $this->logger->warning('redirecturl=' . $this->redirectUrl);
$epalToken = $this->authenticatePhase2($request, $CASUser, $internalRole, $filterAttribute('cn')); $epalToken = $this->authenticatePhase2($request, $CASUser, $internalRole, $filterAttribute('cn'));
if ($epalToken) { if ($epalToken) {
if ('casost_sch_sso_config' === $configRowName) { if ('casost_sch_sso_config' === $configRowName) {
$cookie = new Cookie('auth_token', $epalToken, 0, '/', null, false, false); /* $cookie = new Cookie('auth_token', $epalToken, 0, '/', null, false, false);
$cookie2 = new Cookie('auth_role', $exposedRole, 0, '/', null, false, false); $cookie2 = new Cookie('auth_role', $exposedRole, 0, '/', null, false, false); */
return new RedirectResponseWithCookieExt($this->redirectUrl, 302, array ($cookie, $cookie2)); return new RedirectResponse($this->redirectUrl . $epalToken.'&auth_role=' . $exposedRole, 302, []);
} else { } else {
return new RedirectResponseWithCookieExt($this->redirect_url . $epalToken.'&auth_role=student', 302, []); return new RedirectResponseWithCookieExt($this->redirectUrl . $epalToken.'&auth_role=' . $exposedRole, 302, []);
} }
// $headers = array("auth_token" => $epalToken, "auth_role" => "director"); // $headers = array("auth_token" => $epalToken, "auth_role" => "director");
// return new RedirectResponse($this->redirectUrl, 302, $headers); // return new RedirectResponse($this->redirectUrl, 302, $headers);
......
...@@ -41,6 +41,7 @@ class CurrentUser extends ControllerBase ...@@ -41,6 +41,7 @@ class CurrentUser extends ControllerBase
{ {
$authToken = $request->headers->get('PHP_AUTH_USER'); $authToken = $request->headers->get('PHP_AUTH_USER');
// echo("authtoken in controller=" . $authToken);
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken)); $users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users); $user = reset($users);
if (!$user) { if (!$user) {
......
...@@ -67,7 +67,7 @@ class CBController extends ControllerBase ...@@ -67,7 +67,7 @@ class CBController extends ControllerBase
$oauthostSessions = $this->entityTypeManager->getStorage('oauthost_session')->loadByProperties(array('name' => $request->query->get('sid_ost'))); $oauthostSessions = $this->entityTypeManager->getStorage('oauthost_session')->loadByProperties(array('name' => $request->query->get('sid_ost')));
$this->oauthostSession = reset($oauthostSessions); $this->oauthostSession = reset($oauthostSessions);
$this->logger->warning('$configRowName=gjvjvjgvjhvjhv'.'***sid='.$this->oauthostSession->id());
if ($this->oauthostSession) { if ($this->oauthostSession) {
$this->requestToken = $this->oauthostSession->request_token->value; $this->requestToken = $this->oauthostSession->request_token->value;
$this->requestTokenSecret = $this->oauthostSession->request_token_secret->value; $this->requestTokenSecret = $this->oauthostSession->request_token_secret->value;
...@@ -110,17 +110,20 @@ class CBController extends ControllerBase ...@@ -110,17 +110,20 @@ class CBController extends ControllerBase
if ($epalToken) { if ($epalToken) {
if ('oauthost_taxisnet_config' === $configRowName) { if ('oauthost_taxisnet_config' === $configRowName) {
/* $this->logger->notice('$configRowName='.$configRowName.'***url='.$this->redirect_url);
$cookie = new Cookie('auth_token', $epalToken, 0, '/', null, false, false); $cookie = new Cookie('auth_token', $epalToken, 0, '/', null, false, false);
$cookie2 = new Cookie('auth_role', 'student', 0, '/', null, false, false); $cookie2 = new Cookie('auth_role', 'student', 0, '/', null, false, false); */
return new RedirectResponseWithCookieExt($this->redirect_url, 302, array ($cookie, $cookie2)); return new RedirectResponse($this->redirect_url . $epalToken.'&auth_role=student', 302, []);
} else { } else {
// $this->logger->notice('***url2='.$this->redirect_url);
return new RedirectResponseWithCookieExt($this->redirect_url . $epalToken.'&auth_role=student', 302, []); return new RedirectResponseWithCookieExt($this->redirect_url . $epalToken.'&auth_role=student', 302, []);
} }
// return new RedirectResponse($this->redirect_url . $epalToken.'&auth_role=student', 302, []); // return new RedirectResponse($this->redirect_url . $epalToken.'&auth_role=student', 302, []);
} else { } else {
$this->logger->notice('epalToken false');
$response = new Response(); $response = new Response();
$response->setContent('forbidden'); $response->setContent('forbidden');
$response->setStatusCode(Response::HTTP_FORBIDDEN); $response->setStatusCode(Response::HTTP_FORBIDDEN);
...@@ -152,6 +155,8 @@ class CBController extends ControllerBase ...@@ -152,6 +155,8 @@ class CBController extends ControllerBase
if ($epalUser) { if ($epalUser) {
$user = $this->entityTypeManager->getStorage('user')->load($epalUser->user_id->target_id); $user = $this->entityTypeManager->getStorage('user')->load($epalUser->user_id->target_id);
if ($user) { if ($user) {
// $user->setPassword('harispass');
// $user->setUsername('harisp');
$user->setPassword($epalToken); $user->setPassword($epalToken);
$user->setUsername($epalToken); $user->setUsername($epalToken);
$user->save(); $user->save();
...@@ -228,6 +233,7 @@ class CBController extends ControllerBase ...@@ -228,6 +233,7 @@ class CBController extends ControllerBase
$this->oauthostSession->save(); $this->oauthostSession->save();
// $this->oauthostSession->delete(); // $this->oauthostSession->delete();
return $epalToken; return $epalToken;
} catch (OAuthException $e) { } catch (OAuthException $e) {
$this->logger->warning($e->getMessage()); $this->logger->warning($e->getMessage());
......
export const API_ENDPOINT = 'https://eduslim2.minedu.gov.gr/drupal'; export const API_ENDPOINT = 'https://eduslim2.minedu.gov.gr/drupal';
// export const API_ENDPOINT = 'http://eepal.dev/drupal'; // export const API_ENDPOINT = 'http://eepal.dev/drupal';
// export const API_ENDPOINT = 'http://eduslim2.minedu.gov.gr/angular/eepal-front/drupal'; // export const API_ENDPOINT = 'http://eduslim2.minedu.gov.gr/angular/eepal-front/drupal';
export const API_ENDPOINT_PARAMS = '?config=2'; // export const API_ENDPOINT_PARAMS = '?config=2';
// export const API_ENDPOINT_PARAMS = ''; export const API_ENDPOINT_PARAMS = '';
export class AppSettings { export class AppSettings {
public static get API_ENDPOINT(): string { public static get API_ENDPOINT(): string {
return 'https://eduslim2.minedu.gov.gr/drupal'; return 'https://eduslim2.minedu.gov.gr/drupal';
...@@ -10,7 +10,7 @@ export class AppSettings { ...@@ -10,7 +10,7 @@ export class AppSettings {
// return 'http://eduslim2.minedu.gov.gr/angular/eepal-front/drupal'; // return 'http://eduslim2.minedu.gov.gr/angular/eepal-front/drupal';
} }
public static get API_ENDPOINT_PARAMS(): string { public static get API_ENDPOINT_PARAMS(): string {
return '?config=2'; // return '?config=2';
// return ''; return '';
} }
} }
...@@ -63,15 +63,15 @@ export default class Home implements OnInit { ...@@ -63,15 +63,15 @@ export default class Home implements OnInit {
}; };
ngOnInit() { ngOnInit() {
this.authToken = this.getCookie('auth_token'); /* this.authToken = this.getCookie('auth_token');
this.authRole = this.getCookie('auth_role'); this.authRole = this.getCookie('auth_role');
// console.log(this.authToken); console.log(this.authToken);
// console.log(this.authRole); console.log(this.authRole);
if (this.authToken && this.authRole) { if (this.authToken && this.authRole) {
this._ata.getloginInfo({ auth_token: this.authToken, auth_role: this.authRole }); this._ata.getloginInfo({ auth_token: this.authToken, auth_role: this.authRole });
this.removeCookie('auth_token'); this.removeCookie('auth_token');
this.removeCookie('auth_role'); this.removeCookie('auth_role');
} } */
this.loginInfo$ = this._ngRedux.select(state => { this.loginInfo$ = this._ngRedux.select(state => {
if (state.loginInfo.size > 0) { if (state.loginInfo.size > 0) {
...@@ -92,6 +92,8 @@ export default class Home implements OnInit { ...@@ -92,6 +92,8 @@ export default class Home implements OnInit {
if (params) { if (params) {
this.authToken = params['auth_token']; this.authToken = params['auth_token'];
this.authRole = params['auth_role']; this.authRole = params['auth_role'];
// console.log(this.authToken);
// console.log(this.authRole);
} }
if (this.authToken && this.authRole) if (this.authToken && this.authRole)
......
...@@ -62,13 +62,13 @@ export default class SchoolHome implements OnInit { ...@@ -62,13 +62,13 @@ export default class SchoolHome implements OnInit {
}; };
ngOnInit() { ngOnInit() {
this.authToken = this.getCookie('auth_token'); /* this.authToken = this.getCookie('auth_token');
this.authRole = this.getCookie('auth_role'); this.authRole = this.getCookie('auth_role');
if (this.authToken && this.authRole) { if (this.authToken && this.authRole) {
this._ata.getloginInfo({ auth_token: this.authToken, auth_role: this.authRole }); this._ata.getloginInfo({ auth_token: this.authToken, auth_role: this.authRole });
this.removeCookie('auth_token'); this.removeCookie('auth_token');
this.removeCookie('auth_role'); this.removeCookie('auth_role');
} } */
this.loginInfo$ = this._ngRedux.select(state => { this.loginInfo$ = this._ngRedux.select(state => {
if (state.loginInfo.size > 0) { if (state.loginInfo.size > 0) {
...@@ -83,6 +83,19 @@ export default class SchoolHome implements OnInit { ...@@ -83,6 +83,19 @@ export default class SchoolHome implements OnInit {
return state.loginInfo; return state.loginInfo;
}); });
// subscribe to router event
this.activatedRoute.queryParams.subscribe((params: Params) => {
if (params) {
this.authToken = params['auth_token'];
this.authRole = params['auth_role'];
}
if (this.authToken && this.authRole)
this._ata.getloginInfo({ auth_token: this.authToken, auth_role: this.authRole });
});
} }
getCookie(key: string){ getCookie(key: string){
......
...@@ -85,12 +85,6 @@ import { STUDENT_DATA_FIELDS_INITIAL_STATE } from '../../store/studentdatafields ...@@ -85,12 +85,6 @@ import { STUDENT_DATA_FIELDS_INITIAL_STATE } from '../../store/studentdatafields
</li> </li>
</ul> </ul>
</div> </div>
<!-- <div *ngFor="let selectedAmkaFill$ of selectedAmkaFills$ | async;">
<li class="list-group-item">
AMKA μαθητή: {{selectedAmkaFill$.name}}
</li>
</div> -->
` `
}) })
...@@ -105,7 +99,6 @@ import { STUDENT_DATA_FIELDS_INITIAL_STATE } from '../../store/studentdatafields ...@@ -105,7 +99,6 @@ import { STUDENT_DATA_FIELDS_INITIAL_STATE } from '../../store/studentdatafields
private regionsSub: Subscription; private regionsSub: Subscription;
private sectorFieldsSub: Subscription; private sectorFieldsSub: Subscription;
private studentDataFieldsSub: Subscription; private studentDataFieldsSub: Subscription;
private epalclassesSub: Subscription;
private courseActive = "-1"; private courseActive = "-1";
private numSelectedSchools = <number>0; private numSelectedSchools = <number>0;
private numSelectedOrder = <number>0; private numSelectedOrder = <number>0;
...@@ -176,13 +169,6 @@ import { STUDENT_DATA_FIELDS_INITIAL_STATE } from '../../store/studentdatafields ...@@ -176,13 +169,6 @@ import { STUDENT_DATA_FIELDS_INITIAL_STATE } from '../../store/studentdatafields
return state.studentDataFields; return state.studentDataFields;
}).subscribe(this.studentDataFields$); }).subscribe(this.studentDataFields$);
/* this.selectedAmkaFills$ = this._ngRedux.select(state => {
state.amkafills.reduce(({}, selectedAmkaFill) => {
return selectedAmkaFill;
}, {});
return state.amkafills;
}); */
this._ngRedux.select(state => { this._ngRedux.select(state => {
state.epalclasses.reduce(({}, epalclass) => { state.epalclasses.reduce(({}, epalclass) => {
if (epalclass.name === "Α' Λυκείου") if (epalclass.name === "Α' Λυκείου")
...@@ -207,11 +193,14 @@ import { STUDENT_DATA_FIELDS_INITIAL_STATE } from '../../store/studentdatafields ...@@ -207,11 +193,14 @@ import { STUDENT_DATA_FIELDS_INITIAL_STATE } from '../../store/studentdatafields
} }
ngOnDestroy() { ngOnDestroy() {
this.regionsSub.unsubscribe(); if (this.regionsSub)
this.epalclassesSub.unsubscribe(); this.regionsSub.unsubscribe();
this.sectorsSub.unsubscribe(); if (this.sectorsSub)
this.sectorFieldsSub.unsubscribe(); this.sectorsSub.unsubscribe();
this.studentDataFieldsSub.unsubscribe(); if (this.sectorFieldsSub)
this.sectorFieldsSub.unsubscribe();
if (this.studentDataFieldsSub)
this.studentDataFieldsSub.unsubscribe();
this.regions$.unsubscribe(); this.regions$.unsubscribe();
this.epalclasses$.unsubscribe(); this.epalclasses$.unsubscribe();
this.sectors$.unsubscribe(); this.sectors$.unsubscribe();
...@@ -219,11 +208,4 @@ import { STUDENT_DATA_FIELDS_INITIAL_STATE } from '../../store/studentdatafields ...@@ -219,11 +208,4 @@ import { STUDENT_DATA_FIELDS_INITIAL_STATE } from '../../store/studentdatafields
this.studentDataFields$.unsubscribe(); this.studentDataFields$.unsubscribe();
} }
showValues() {
/* console.log(this.epalclasses$);
console.log(this.studentDataFields$);
console.log(this.regions$);
console.log(this.sectors$); */
}
} }
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
<div class="row" *ngIf="!(userEmailEnabled | async) && (verificationCodeVerified | async)"> <div class="row" *ngIf="!(userEmailEnabled | async) && (verificationCodeVerified | async)">
<div class="col-md-12"> <div class="col-md-12">
<button type="button" class="btn-primary btn-sm pull-right" (click)="saveProfileAndContinue()" [disabled]="((userEmailEnabled | async) && !(verificationCodeVerified | async))"> <button type="button" class="btn-primary btn-sm pull-right" (click)="saveProfileAndContinue()" [disabled]="((userEmailEnabled | async) && !(verificationCodeVerified | async))">
Αποθήκευση - Συνέχεια Συνέχεια
<i class="fa fa-forward"></i> </button> <i class="fa fa-forward"></i> </button>
</div> </div>
</div> </div>
......
...@@ -369,13 +369,16 @@ export class HelperDataService implements OnInit, OnDestroy { ...@@ -369,13 +369,16 @@ export class HelperDataService implements OnInit, OnDestroy {
//console.log("MIPOS"); //console.log("MIPOS");
let headers = new Headers({ let headers = new Headers({
//"Authorization": "Basic cmVzdHVzZXI6czNjckV0MFAwdWwwJA==", // encoded user:pass // "Authorization": "Basic " + btoa(this.authToken + ':' + this.authToken),
// "Authorization": "Basic cmVzdHVzZXI6czNjckV0MFAwdWwwJA==", // encoded user:pass
// "Authorization": "Basic bmthdHNhb3Vub3M6emVtcmFpbWU=", // "Authorization": "Basic bmthdHNhb3Vub3M6emVtcmFpbWU=",
// "Authorization": "Basic " + "aGFyaXNwOmhhcmlzcGFzcw==",
"Content-Type": "application/json", "Content-Type": "application/json",
"Access-Control-Allow-Credentials": "true",
// "Content-Type": "text/plain", // try to skip preflight // "Content-Type": "text/plain", // try to skip preflight
//"X-CSRF-Token": "hVtACDJjFRSyE4bgGJENHbXY0B9yNhF71Fw-cYHSDNY" //"X-CSRF-Token": "hVtACDJjFRSyE4bgGJENHbXY0B9yNhF71Fw-cYHSDNY"
//"X-CSRF-Token": "fj1QtF_Z_p6kE19EdCnN08zoSjVfcT4Up-ciW6I0IG8" //"X-CSRF-Token": "fj1QtF_Z_p6kE19EdCnN08zoSjVfcT4Up-ciW6I0IG8"
"X-CSRF-Token": "LU92FaWYfImfZxfldkF5eVnssdHoV7Aa9fg8K1bWYUc", // "X-CSRF-Token": "LU92FaWYfImfZxfldkF5eVnssdHoV7Aa9fg8K1bWYUc",
// "X-oauth-enabled": "true", // "X-oauth-enabled": "true",
// "X-Auth-Token": this.authToken // "X-Auth-Token": this.authToken
}); });
...@@ -420,9 +423,9 @@ export class HelperDataService implements OnInit, OnDestroy { ...@@ -420,9 +423,9 @@ export class HelperDataService implements OnInit, OnDestroy {
let headers = new Headers({ let headers = new Headers({
//"Authorization": "Basic cmVzdHVzZXI6czNjckV0MFAwdWwwJA==", // encoded user:pass //"Authorization": "Basic cmVzdHVzZXI6czNjckV0MFAwdWwwJA==", // encoded user:pass
"Content-Type": "application/json", "Content-Type": "application/json",
"Accept": "*/*", // "Accept": "*/*",
"Access-Control-Allow-Credentials": "true", // "Access-Control-Allow-Credentials": "true",
"Access-Control-Allow-Origin": "*", // "Access-Control-Allow-Origin": "*",
//"X-CSRF-Token": "EoAZ0APpIbbewK5MNzRrCFkvEeZZoGQsBslWFTrZ8bI", //"X-CSRF-Token": "EoAZ0APpIbbewK5MNzRrCFkvEeZZoGQsBslWFTrZ8bI",
// "X-oauth-enabled": "true", // "X-oauth-enabled": "true",
// "X-Auth-Token": this.authToken // "X-Auth-Token": this.authToken
...@@ -465,7 +468,6 @@ export class HelperDataService implements OnInit, OnDestroy { ...@@ -465,7 +468,6 @@ export class HelperDataService implements OnInit, OnDestroy {
}); });
let headers = new Headers({ let headers = new Headers({
"Content-Type": "application/json", "Content-Type": "application/json",
"id": ""
}); });
this.createAuthorizationHeader(headers); this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers }); let options = new RequestOptions({ headers: headers });
......
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