@@ -182,8 +182,8 @@ export async function deleteAccessToken() {
182182 try {
183183 return await removeFile ( STORAGE_PATHS . access_token , { dir : DEFAULT_DIRECTORY } ) ;
184184 } catch ( error ) {
185- console . error ( "Error deleting access token:" , error ) ;
186- throw new Error ( "Error deleting access token" ) ;
185+ // File might not exist, that's okay - fail silently
186+ console . debug ( "deleteAccessToken: file may not exist" , error ) ;
187187 }
188188}
189189
@@ -206,10 +206,32 @@ export async function getUserProfileFromStorage() {
206206 }
207207}
208208
209+ export async function deleteUserProfile ( ) {
210+ try {
211+ return await removeFile ( STORAGE_PATHS . user_profile , { dir : DEFAULT_DIRECTORY } ) ;
212+ } catch ( error ) {
213+ // File might not exist, that's okay - fail silently
214+ console . debug ( "deleteUserProfile: file may not exist" , error ) ;
215+ }
216+ }
217+
209218
210- export async function handleLogin ( ) {
219+ export async function handleLogin ( forceNew : boolean = false ) {
211220 setRecoil ( authLoadingState , true )
212221 try {
222+ // If forcing new account, delete stored token first
223+ if ( forceNew ) {
224+ try {
225+ await deleteAccessToken ( ) ;
226+ await deleteUserProfile ( ) ;
227+ } catch {
228+ // Tokens might not exist, that's fine
229+ }
230+ pushNotification ( 'Choose an account' ) ;
231+ await openAuthWindow ( ) ;
232+ return ;
233+ }
234+
213235 const storedAccessToken = await getAccessTokenFromStorage ( ) ;
214236 if ( storedAccessToken ) {
215237 handleLoadFrom ( storedAccessToken ) ;
0 commit comments