WIP: Fixing user locking problem through flood system

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