Skip to content
Snippets Groups Projects
Commit b27b1c7e authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #13695 TIME 1:45 front logout cas

parent b1627f7e
No related branches found
No related tags found
No related merge requests found
...@@ -313,10 +313,9 @@ class AuthenticationController ...@@ -313,10 +313,9 @@ class AuthenticationController
$loggingMethod = CoreConfigModel::getLoggingMethod(); $loggingMethod = CoreConfigModel::getLoggingMethod();
if ($loggingMethod['id'] == 'cas') { if ($loggingMethod['id'] == 'cas') {
AuthenticationController::casDisconnection(); $res = AuthenticationController::casDisconnection();
} }
return $response->withJson(['logoutUrl' => $res['logoutUrl'], 'redirectUrl' => $res['redirectUrl']]);
return $response->withStatus(204);
} }
private static function standardConnection(array $args) private static function standardConnection(array $args)
...@@ -461,9 +460,8 @@ class AuthenticationController ...@@ -461,9 +460,8 @@ class AuthenticationController
} }
\phpCAS::setFixedServiceURL(UrlController::getCoreUrl() . 'dist/index.html'); \phpCAS::setFixedServiceURL(UrlController::getCoreUrl() . 'dist/index.html');
\phpCAS::setNoClearTicketsFromUrl(); \phpCAS::setNoClearTicketsFromUrl();
\phpCAS::logout(); $logoutUrl = \phpCAS::getServerLogoutURL();
return ['logoutUrl' => $logoutUrl, 'redirectUrl' => UrlController::getCoreUrl() . 'dist/index.html'];
return true;
} }
public function getRefreshedToken(Request $request, Response $response) public function getRefreshedToken(Request $request, Response $response)
......
...@@ -5,6 +5,7 @@ import { LocalStorageService } from './local-storage.service'; ...@@ -5,6 +5,7 @@ import { LocalStorageService } from './local-storage.service';
import { NotificationService } from './notification/notification.service'; import { NotificationService } from './notification/notification.service';
import { HeaderService } from './header.service'; import { HeaderService } from './header.service';
import { Observable, Subject } from 'rxjs'; import { Observable, Subject } from 'rxjs';
import { tap } from 'rxjs/operators';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -89,11 +90,28 @@ export class AuthService { ...@@ -89,11 +90,28 @@ export class AuthService {
} }
async logout(cleanUrl: boolean = true) { async logout(cleanUrl: boolean = true) {
if (['cas', 'keycloak'].indexOf(this.authMode) > -1) {
this.SsoLogout(cleanUrl);
} else {
this.redirectAfterLogout(cleanUrl);
await this.router.navigate(['/login']);
}
}
SsoLogout(cleanUrl: boolean = true) {
this.http.get('../rest/authenticate/logout').pipe(
tap(async (data: any) => {
this.redirectAfterLogout(cleanUrl);
window.location.href = data.logoutUrl + '?service=' + encodeURI(data.redirectUrl);
})
).subscribe();
}
redirectAfterLogout(cleanUrl: boolean = true) {
if (this.getToken() !== null && cleanUrl) { if (this.getToken() !== null && cleanUrl) {
this.cleanUrl(JSON.parse(atob(this.getToken().split('.')[1])).user.id); this.cleanUrl(JSON.parse(atob(this.getToken().split('.')[1])).user.id);
} }
this.headerService.setUser(); this.headerService.setUser();
await this.router.navigate(['/login']);
this.clearTokens(); this.clearTokens();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment