Skip to content

Commit adc50a7

Browse files
committed
more robust login handling by deleting corrupt user.json file
If a user.json file cannot be loaded, delete it automatically to avoid users to get stuck in 'something went wrong' during layout. Older versions of GB wouldn't find the access-token in the user.json file anymore, which would be completely removed via #4165
1 parent 900316a commit adc50a7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

crates/gitbutler-core/src/users/controller.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ impl Controller {
1919
}
2020

2121
pub fn get_user(&self) -> anyhow::Result<Option<User>> {
22-
self.storage.get().context("failed to get user")
22+
match self.storage.get().context("failed to get user") {
23+
Ok(user) => Ok(user),
24+
Err(err) => {
25+
self.storage.delete().ok();
26+
Err(err)
27+
}
28+
}
2329
}
2430

2531
pub fn set_user(&self, user: &User) -> anyhow::Result<()> {

0 commit comments

Comments
 (0)