mirror of
https://github.com/mikedilger/gossip.git
synced 2024-08-28 17:15:01 +00:00
Deletion of identity
This commit is contained in:
parent
fb72af07a6
commit
439958c6d3
@ -23,7 +23,7 @@ As of right now you can (if you aren't stopped by some bug):
|
||||
- [x] **Creting content**
|
||||
- [x] Generating a key that is kept securely within the client encrypted under a password that you need to unlock it every time you start the client.
|
||||
- [x] Generate or import (hex or bech32) a private key (your identity) (also kept under a password)
|
||||
- [x] Exporting your private key encrypted, or decrypted as bech32 or hex
|
||||
- [x] Exporting your private key encrypted, or decrypted as bech32 or hex, or delete your identity
|
||||
- [x] Choose relays to post to (from among some starting relays, plus ones the client has seen in events), including entering a relay URL directly.
|
||||
- [x] Post root-level text messages
|
||||
- [x] Post replies to other people's text messages
|
||||
|
@ -129,4 +129,25 @@ impl Signer {
|
||||
_ => Err(Error::NoPrivateKey),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn delete_identity(&mut self, pass: &str) -> Result<(), Error> {
|
||||
match self {
|
||||
Signer::Ready(_, epk) => {
|
||||
// Verify their password
|
||||
let _pk = epk.decrypt(pass)?;
|
||||
|
||||
// Delete from database
|
||||
let mut settings = GLOBALS.settings.blocking_write();
|
||||
settings.encrypted_private_key = None;
|
||||
task::spawn(async move {
|
||||
if let Err(e) = settings.save().await {
|
||||
tracing::error!("{}", e);
|
||||
}
|
||||
});
|
||||
*self = Signer::Fresh;
|
||||
Ok(())
|
||||
}
|
||||
_ => Err(Error::NoPrivateKey),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,6 +108,30 @@ pub(super) fn update(app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Fr
|
||||
app.password.zeroize();
|
||||
app.password = "".to_owned();
|
||||
}
|
||||
|
||||
ui.add_space(10.0);
|
||||
ui.separator();
|
||||
ui.add_space(10.0);
|
||||
ui.heading("DELETE This Identity");
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(10.0);
|
||||
ui.label("Enter Password To Delete: ");
|
||||
ui.add(TextEdit::singleline(&mut app.password).password(true));
|
||||
});
|
||||
|
||||
if ui.button("DELETE (Cannot be undone!)").clicked() {
|
||||
match GLOBALS
|
||||
.signer
|
||||
.blocking_write()
|
||||
.delete_identity(&app.password)
|
||||
{
|
||||
Ok(_) => app.status = "Identity deleted.".to_string(),
|
||||
Err(e) => app.status = format!("{}", e),
|
||||
}
|
||||
app.password.zeroize();
|
||||
app.password = "".to_owned();
|
||||
}
|
||||
} else if GLOBALS.signer.blocking_read().is_loaded() {
|
||||
ui.heading("Password Needed");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user