Skip to content

Commit b2f2a09

Browse files
committed
mobx: Updated session store to support additional session types
1 parent 46e9424 commit b2f2a09

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

app/src/store/models/session.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ export default class Session {
5151
get typeLabel() {
5252
switch (this.type) {
5353
case LIT.SessionType.TYPE_MACAROON_READONLY:
54-
return 'Readonly Macaroon';
54+
return 'Read-Only';
5555
case LIT.SessionType.TYPE_MACAROON_ADMIN:
56-
return 'Admin Macaroon';
56+
return 'Admin';
5757
case LIT.SessionType.TYPE_MACAROON_CUSTOM:
58-
return 'Custom Macaroon';
58+
return 'Custom';
5959
case LIT.SessionType.TYPE_UI_PASSWORD:
6060
return 'LiT UI Password';
6161
}

app/src/store/stores/sessionStore.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ export default class SessionStore {
8383
s.label.startsWith('Default Session'),
8484
).length;
8585
const countText = count === 0 ? '' : `(${count})`;
86-
await this.addSession(`Default Session ${countText}`, MAX_DATE);
86+
await this.addSession(
87+
`Default Session ${countText}`,
88+
LIT.SessionType.TYPE_MACAROON_ADMIN,
89+
MAX_DATE,
90+
);
8791
}
8892
} catch (error: any) {
8993
this._store.appView.handleError(error, 'Unable to fetch sessions');
@@ -93,11 +97,16 @@ export default class SessionStore {
9397
/**
9498
* Adds a new session
9599
* @param label the user defined label for this session
100+
* @param type the type of session being created (admin, read-only, etc)
96101
* @param expiry how long the session should be valid for
97102
* @param mailboxServerAddr the address where the mailbox server is reachable
98103
* @param devServer whether the mailbox server is a dev server that has no valid TLS cert
99104
*/
100-
async addSession(label: string, expiry: Date) {
105+
async addSession(
106+
label: string,
107+
type: LIT.SessionTypeMap[keyof LIT.SessionTypeMap],
108+
expiry: Date,
109+
) {
101110
try {
102111
this._store.log.info(`submitting session with label ${label}`, {
103112
expiry,
@@ -107,7 +116,7 @@ export default class SessionStore {
107116

108117
const { session } = await this._store.api.lit.addSession(
109118
label,
110-
LIT.SessionType.TYPE_UI_PASSWORD,
119+
type,
111120
expiry,
112121
this.proxyServer,
113122
!IS_PROD,

0 commit comments

Comments
 (0)