Timshel
3 days ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
12 additions and
11 deletions
-
src/db/models/user.rs
-
src/static/scripts/admin_users.js
|
|
@ -284,21 +284,22 @@ impl User { |
|
|
|
|
|
|
|
db_run! {conn: |
|
|
|
sqlite, mysql { |
|
|
|
match diesel::replace_into(users::table) |
|
|
|
.values(UserDb::to_db(self)) |
|
|
|
let value = UserDb::to_db(self); |
|
|
|
// Don't use replace_into() since it wants to delete the record first.
|
|
|
|
match diesel::update(users::table) |
|
|
|
.filter(users::uuid.eq(&self.uuid)) |
|
|
|
.set(&value) |
|
|
|
.execute(conn) |
|
|
|
{ |
|
|
|
Ok(_) => Ok(()), |
|
|
|
// Record already exists and causes a Foreign Key Violation because replace_into() wants to delete the record first.
|
|
|
|
Err(diesel::result::Error::DatabaseError(diesel::result::DatabaseErrorKind::ForeignKeyViolation, _)) => { |
|
|
|
diesel::update(users::table) |
|
|
|
.filter(users::uuid.eq(&self.uuid)) |
|
|
|
.set(UserDb::to_db(self)) |
|
|
|
Ok(1) => Ok(()), |
|
|
|
Ok(_) => { |
|
|
|
diesel::insert_into(users::table) |
|
|
|
.values(value) |
|
|
|
.execute(conn) |
|
|
|
.map_res("Error saving user") |
|
|
|
} |
|
|
|
Err(e) => Err(e.into()), |
|
|
|
}.map_res("Error saving user") |
|
|
|
}.map_res("Error updating user") |
|
|
|
} |
|
|
|
postgresql { |
|
|
|
let value = UserDb::to_db(self); |
|
|
|
|
|
@ -33,11 +33,11 @@ function deleteSSOUser(event) { |
|
|
|
alert("Required parameters not found!"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
const input_email = prompt(`To delete user "${email}", please type the email below`); |
|
|
|
const input_email = prompt(`To delete user "${email}" SSO association, please type the email below`); |
|
|
|
if (input_email != null) { |
|
|
|
if (input_email == email) { |
|
|
|
_delete(`${BASE_URL}/admin/users/${id}/sso`, |
|
|
|
"User SSO Associtation deleted correctly", |
|
|
|
"User SSO association deleted correctly", |
|
|
|
"Error deleting user SSO association" |
|
|
|
); |
|
|
|
} else { |
|
|
|