MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / SessionStore

Class SessionStore

ui/src/stores/SessionStore.ts:18–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16import { HandleError, HandleLoginError } from "./helpers";
17
18class SessionStore extends EventEmitter {
19 client: InternalServiceClient;
20 user?: User;
21 tenants: UserTenantLink[];
22 applications: UserApplicationLink[];
23 deviceProfiles: UserDeviceProfileLink[];
24
25 constructor() {
26 super();
27
28 this.client = new InternalServiceClient("");
29 this.tenants = [];
30 this.applications = [];
31 this.deviceProfiles = [];
32
33 this.fetchProfile(() => {});
34 }
35
36 login = (email: string, password: string, callbackFunc: () => void) => {
37 const req = new LoginRequest();
38 req.setEmail(email);
39 req.setPassword(password);
40 this.client.login(req, {}, (err, resp) => {
41 if (err !== null) {
42 HandleLoginError(err);
43 return;
44 }
45
46 this.setToken(resp.getJwt());
47 this.fetchProfile(callbackFunc);
48 });
49 };
50
51 openIdConnectLogin = (req: OpenIdConnectLoginRequest, callbackFunc: () => void) => {
52 this.client.openIdConnectLogin(req, {}, (err, resp) => {
53 if (err !== null) {
54 HandleLoginError(err);
55 return;
56 }
57
58 this.setToken(resp.getToken());
59 this.fetchProfile(callbackFunc);
60 });
61 };
62
63 oAuth2Login = (req: OAuth2LoginRequest, callbackFunc: () => void) => {
64 this.client.oAuth2Login(req, {}, (err, resp) => {
65 if (err !== null) {
66 HandleLoginError(err);
67 return;
68 }
69
70 this.setToken(resp.getToken());
71 this.fetchProfile(callbackFunc);
72 });
73 };
74
75 logout = (emit: boolean, callbackFunc: () => void) => {

Callers

nothing calls this directly

Calls 4

HandleLoginErrorFunction · 0.90
HandleErrorFunction · 0.90
loginMethod · 0.80
profileMethod · 0.80

Tested by

no test coverage detected