in preparation to moving userdata into app, we switched to arbitrary groups
This commit is contained in:
@ -272,7 +272,7 @@ ORDER BY departure DESC
|
||||
if let Ok(log_to_finalize) = TryInto::<LogToFinalize>::try_into(log.clone()) {
|
||||
//TODO: fix clone() above
|
||||
|
||||
if !boat.shipmaster_allowed(created_by_user).await {
|
||||
if !boat.shipmaster_allowed(db, created_by_user).await {
|
||||
return Err(LogbookCreateError::UserNotAllowedToUseBoat);
|
||||
}
|
||||
|
||||
@ -343,7 +343,7 @@ ORDER BY departure DESC
|
||||
}
|
||||
}
|
||||
|
||||
if !boat.shipmaster_allowed(created_by_user).await {
|
||||
if !boat.shipmaster_allowed(db, created_by_user).await {
|
||||
return Err(LogbookCreateError::UserNotAllowedToUseBoat);
|
||||
}
|
||||
|
||||
@ -452,7 +452,7 @@ ORDER BY departure DESC
|
||||
return Err(LogbookUpdateError::SteeringPersonNotInRowers);
|
||||
}
|
||||
|
||||
if !boat.shipmaster_allowed(user).await && self.shipmaster != user.id {
|
||||
if !boat.shipmaster_allowed_tx(db, user).await && self.shipmaster != user.id {
|
||||
//second part: shipmaster has entered a different user, then the user should be able to
|
||||
//`home` it
|
||||
return Err(LogbookUpdateError::UserNotAllowedToUseBoat);
|
||||
@ -471,7 +471,7 @@ ORDER BY departure DESC
|
||||
return Err(LogbookUpdateError::ArrivalNotAfterDeparture);
|
||||
}
|
||||
let today = Utc::now().date_naive();
|
||||
if arr.date() != today && !user.is_admin {
|
||||
if arr.date() != today && !user.has_role_tx(db, "admin").await {
|
||||
return Err(LogbookUpdateError::OnlyAllowedToEndTripsEndingToday);
|
||||
}
|
||||
|
||||
@ -506,7 +506,7 @@ 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.is_admin || user.id == self.shipmaster {
|
||||
if user.has_role(db, "admin").await || user.id == self.shipmaster {
|
||||
sqlx::query!("DELETE FROM logbook WHERE id=?", self.id)
|
||||
.execute(db)
|
||||
.await
|
||||
|
Reference in New Issue
Block a user