MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / saveUserCredentials

Function saveUserCredentials

cli/src/utils/auth.ts:164–184  ·  view source on GitHub ↗
(user: User)

Source from the content-addressed store, hash-verified

162 * Save user credentials to file system.
163 */
164export const saveUserCredentials = (user: User): void => {
165 const configDir = getConfigDir()
166 const credentialsPath = getCredentialsPath()
167
168 try {
169 if (!fs.existsSync(configDir)) {
170 fs.mkdirSync(configDir, { recursive: true })
171 }
172
173 const updatedData = { ...readCredentialsFile(), default: user }
174 fs.writeFileSync(credentialsPath, JSON.stringify(updatedData, null, 2))
175 } catch (error) {
176 logger.error(
177 {
178 error: error instanceof Error ? error.message : String(error),
179 },
180 'Error saving credentials',
181 )
182 throw error
183 }
184}
185
186/**
187 * Clear user credentials from file system.

Callers 5

runPlainLoginFunction · 0.90
useLoginMutationFunction · 0.90

Calls 3

readCredentialsFileFunction · 0.85
getConfigDirFunction · 0.70
getCredentialsPathFunction · 0.70

Tested by

no test coverage detected