Skip to content

Commit

Permalink
Setting to make login notification optional (#1874)
Browse files Browse the repository at this point in the history
  • Loading branch information
sourishkrout authored Dec 19, 2024
1 parent 2b9983d commit 21f26b0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,11 @@
"default": true,
"markdownDescription": "If set to `true`, the auth token file will be deleted after the session ends"
},
"runme.app.showLoginNotification": {
"type": "boolean",
"default": true,
"markdownDescription": "If set to `true`, a notification will be shown when the user successfully logged in"
},
"runme.aiBaseURL": {
"type": "string",
"default": "http://localhost:8877/api",
Expand Down
11 changes: 10 additions & 1 deletion src/extension/provider/statefulAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ import { v4 as uuidv4 } from 'uuid'
import fetch from 'node-fetch'
import jwt, { JwtPayload } from 'jsonwebtoken'

import { getAuthTokenPath, getDeleteAuthToken, getRunmeAppUrl } from '../../utils/configuration'
import {
getAuthTokenPath,
getDeleteAuthToken,
getRunmeAppUrl,
getShowLoginNotification,
} from '../../utils/configuration'
import { AuthenticationProviders, PLATFORM_USER_SIGNED_IN, TELEMETRY_EVENTS } from '../../constants'
import ContextState from '../contextState'
import getLogger from '../logger'
Expand Down Expand Up @@ -679,6 +684,10 @@ export class StatefulAuthProvider implements AuthenticationProvider, Disposable
static showLoginNotification() {
this.assertContext(this.#context)

if (!getShowLoginNotification()) {
return
}

if (!this.#context.globalState.get<boolean>(TELEMETRY_EVENTS.OpenWorkspace, true)) {
return
}
Expand Down
6 changes: 6 additions & 0 deletions src/utils/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const configurationSchema = {
docsUrl: z.string().default(DEFAULT_DOCS_URL),
authTokenPath: z.string().optional(),
deleteAuthToken: z.boolean().default(true),
showLoginNotification: z.boolean().default(true),
},
}

Expand Down Expand Up @@ -462,6 +463,10 @@ const getDeleteAuthToken = () => {
return getCloudConfigurationValue<boolean>('deleteAuthToken', true)
}

const getShowLoginNotification = () => {
return getCloudConfigurationValue<boolean>('showLoginNotification', true)
}

export {
enableServerLogs,
getActionsOpenViewInEditor,
Expand Down Expand Up @@ -497,4 +502,5 @@ export {
getDocsUrl,
getAuthTokenPath,
getDeleteAuthToken,
getShowLoginNotification,
}

0 comments on commit 21f26b0

Please sign in to comment.