Commit 7a86f2e5 authored by Emiliano Balbuena's avatar Emiliano Balbuena

(feat): Destroy session server-side

1 merge request!507WIP: (feat): Minds Pro (development branch) - Release 3
Pipeline #78981153 failed with stages
in 7 minutes and 8 seconds
import { Component } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Client } from '../../services/api';
import { Session } from '../../services/session';
import { AuthService } from '../../services/auth.service';
@Component({
template: ``
})
export class LogoutComponent {
constructor(
public client: Client,
public router: Router,
public route: ActivatedRoute,
public session: Session,
public auth: AuthService,
) {
this.route.url.subscribe(segments => {
this.logout(segments && segments.length>1 && segments[1].toString() === 'all');
this.logout(segments && segments.length > 1 && segments[1].toString() === 'all');
});
}
logout(closeAllSessions: boolean = false) {
let url: string = 'api/v1/authenticate';
if (closeAllSessions)
url += '/all';
this.client.delete(url);
this.session.logout();
this.auth.logout(closeAllSessions);
this.router.navigate(['/login']);
}
}
......@@ -17,7 +17,7 @@
[href]="link.href"
>{{link.title}}</a>
<ng-container *ngIf="session.getLoggedInUser()">
<ng-container *ngIf="currentUser">
<ng-container *ngIf="isStandalone">
<a
class="m-pro--channel-footer--link"
......
import { Component } from '@angular/core';
import { ProChannelService } from "../channel.service";
import { Session } from '../../../../services/session';
import { AuthService } from '../../../../services/auth.service';
export interface SocialProfileMeta {
......@@ -21,11 +22,10 @@ export interface SocialProfileMeta {
export class ProChannelFooterComponent {
constructor(
private channelService: ProChannelService,
protected _session: Session
) {
}
protected channelService: ProChannelService,
protected session: Session,
protected auth: AuthService,
) { }
private socialProfileMeta: SocialProfileMeta[] = [
{
......@@ -260,7 +260,7 @@ export class ProChannelFooterComponent {
}
logout() {
this._session.logout();
this.auth.logout();
}
private getSocialProfileMeta(key: string): SocialProfileMeta {
......@@ -286,14 +286,14 @@ export class ProChannelFooterComponent {
return this.channelService.currentChannel;
}
get session() {
return this._session;
}
get isOwner() {
return this.session.getLoggedInUser() && this.session.getLoggedInUser().guid == this.user.guid;
}
get currentUser() {
return this.session.getLoggedInUser();
}
get currentUsername() {
return this.session.getLoggedInUser().username;
}
......
import { Injectable } from '@angular/core';
import { Client } from './api/client';
import { Session } from './session';
@Injectable()
export class AuthService {
constructor(
protected readonly client: Client,
protected readonly session: Session,
) { }
logout(closeAll: boolean = false): boolean {
let endpoint: string = 'api/v1/authenticate';
if (closeAll) {
endpoint += '/all';
}
this.client.delete(endpoint);
this.session.logout();
return true;
}
}
......@@ -42,6 +42,7 @@ import { InMemoryStorageService } from "./in-memory-storage.service";
import { FeedsService } from "../common/services/feeds.service";
import { ThemeService } from "../common/services/theme.service";
import { GlobalScrollService } from "./ux/global-scroll.service";
import { AuthService } from './auth.service';
export const MINDS_PROVIDERS : any[] = [
{
......@@ -222,4 +223,5 @@ export const MINDS_PROVIDERS : any[] = [
useFactory: ThemeService._,
deps: [ RendererFactory2, Client, Session , Storage ],
},
AuthService,
];
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