fixed logout session issues

parent 62aca96a
......@@ -134,13 +134,14 @@ class CASLogout extends ControllerBase
// phpCAS::logout(array('url'=>$this->redirectUrl));
// phpCAS::logout();
// session_unset();
// session_destroy();
$this->logger->warning("hello from logout");
// \Drupal::service('page_cache_kill_switch')->trigger();
session_unset();
session_destroy();
\Drupal::service('page_cache_kill_switch')->trigger();
// phpCAS::logoutWithRedirectServiceAndUrl('https://sso-test.sch.gr/logout','');
// header('Location: '.'https://sso-test.sch.gr/login?service=https%3A%2F%2Feduslim2.minedu.gov.gr%2Fdrupal%2Fcas%2Flogin%3Fconfig%3D2');
// header('Location: https://sso-test.sch.gr/logout');
// exit;
// return new RedirectResponseWithCookieExt("https://sso-test.sch.gr/logout", 302, []);
// exit(0);
// return new RedirectResponseWithCookieExt("https://sso-test.sch.gr/logout", 302, []);
return $response;
} catch (\Exception $e) {
$this->logger->warning($e->getMessage());
......
......@@ -134,6 +134,9 @@ class OAuthLogout extends ControllerBase
$response->headers->set('Content-Type', 'application/json');
return $response;
}
session_unset();
session_destroy();
\Drupal::service('page_cache_kill_switch')->trigger();
$response = new Response();
$response->setContent('logout successful');
$response->setStatusCode(Response::HTTP_OK);
......
......@@ -13,6 +13,8 @@ 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';
import { CookieService } from 'ngx-cookie';
const HEADER = { headers: new Headers({ 'Content-Type': 'application/json' }) };
......@@ -27,9 +29,11 @@ export class HelperDataService implements OnInit, OnDestroy {
constructor(
private http: Http,
private _ngRedux: NgRedux<IAppState>) {
private _ngRedux: NgRedux<IAppState>,
private _cookieService:CookieService) {
this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
};
ngOnInit() {
......@@ -421,14 +425,8 @@ 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": "*",
//"X-CSRF-Token": "EoAZ0APpIbbewK5MNzRrCFkvEeZZoGQsBslWFTrZ8bI",
// "X-oauth-enabled": "true",
// "X-Auth-Token": this.authToken
});
if (this.authRole === MINISTRY_ROLE)
......@@ -437,8 +435,23 @@ export class HelperDataService implements OnInit, OnDestroy {
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers, withCredentials: true });
let logoutRoute = '/oauth/logout';
if (this.authRole === SCHOOL_ROLE || this.authRole === PDE_ROLE || this.authRole === DIDE_ROLE)
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';
......@@ -446,6 +459,7 @@ export class HelperDataService implements OnInit, OnDestroy {
this.http.post(`${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 => {
......
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