You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

37 lines
1.1 KiB

import {Injectable, OnInit} from '@angular/core';
import {PlayerService} from "./player.service";
import {ProfileRequestData} from "../entities/profile/ProfileRequestData";
import {SteamData} from "../entities/profile/SteamData";
import {SteamIDs} from "../entities/profile/SteamIDs";
@Injectable({
providedIn: 'root'
})
export class AuthService {
static KEY: string = "steam_ids";
steamdata: SteamData | null = null;
steamIds: SteamIDs | null = null;
constructor(private playerService: PlayerService) {
this.playerService.getProfile(null, [ProfileRequestData.STEAM_DATA])
.subscribe((res) => {
this.steamdata = res.steam_data;
this.steamIds = res.steamids
sessionStorage.setItem(AuthService.KEY, JSON.stringify(res.steamids))
})
}
login() {
sessionStorage.removeItem(AuthService.KEY);
window.open("api/auth/login?subdomain=tf3")
}
logout() {
sessionStorage.removeItem(AuthService.KEY);
window.open("api/auth/logout", "_self")
}
isAuth() {
return sessionStorage.getItem(AuthService.KEY) != null;
}
}