fix previous auth records cleanup, update error enums

This commit is contained in:
yggverse 2024-11-20 10:03:46 +02:00
parent cadefe3f1d
commit 3191ff0ff0
2 changed files with 7 additions and 8 deletions

View File

@ -45,12 +45,10 @@ impl Auth {
// Get all records match request
match self.database.records(Some(url)) {
Ok(records) => {
// Cleanup records match `profile_identity_gemini_id` (unauth)
// Cleanup records match `url` (unauth)
for record in records {
if record.profile_identity_gemini_id == profile_identity_gemini_id {
if self.database.delete(record.id).is_err() {
return Err(Error::DatabaseRecordDelete(record.id));
}
if let Err(reason) = self.database.delete(record.id) {
return Err(Error::DatabaseRecordDelete(record.id, reason));
}
}
@ -58,10 +56,11 @@ impl Auth {
let profile_identity_gemini_auth_id =
match self.database.add(profile_identity_gemini_id, url) {
Ok(id) => id,
Err(_) => {
Err(reason) => {
return Err(Error::DatabaseRecordCreate(
profile_identity_gemini_id,
url.to_string(),
reason,
))
}
};

View File

@ -1,8 +1,8 @@
#[derive(Debug)]
pub enum Error {
DatabaseIndex,
DatabaseRecordCreate(i64, String),
DatabaseRecordDelete(i64),
DatabaseRecordCreate(i64, String, sqlite::Error),
DatabaseRecordDelete(i64, sqlite::Error),
DatabaseRecordsRead(String),
MemoryIndex(super::memory::Error),
}