board members can open and close trips for others
All checks were successful
CI/CD Pipeline / test (push) Successful in 10m15s
CI/CD Pipeline / deploy-staging (push) Successful in 5m15s
CI/CD Pipeline / deploy-main (push) Has been skipped

This commit is contained in:
2024-03-16 19:47:04 +01:00
parent 4d634ce313
commit d1fa3e0336
3 changed files with 12 additions and 5 deletions

View File

@ -472,7 +472,7 @@ ORDER BY departure DESC
mut log: LogToFinalize,
) -> Result<(), LogbookUpdateError> {
//TODO: extract common tests with `create()`
if user.id != self.shipmaster {
if !user.has_role_tx(db, "Vorstand").await && user.id != self.shipmaster {
return Err(LogbookUpdateError::NotYourEntry);
}
@ -549,7 +549,10 @@ ORDER BY departure DESC
pub async fn delete(&self, db: &SqlitePool, user: &User) -> Result<(), LogbookDeleteError> {
Log::create(db, format!("{user:?} deleted trip: {self:?}")).await;
if user.has_role(db, "admin").await || user.id == self.shipmaster {
if user.has_role(db, "admin").await
|| user.has_role(db, "Vorstand").await
|| user.id == self.shipmaster
{
sqlx::query!("DELETE FROM logbook WHERE id=?", self.id)
.execute(db)
.await