Merge branch 'single-user-edit-page' of https://git.hofer.link/Ruderverein-Donau-Linz/rowt into single-user-edit-page
This commit is contained in:
commit
bb78441cc4
@ -499,7 +499,7 @@ impl User {
|
|||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
if !role.hide_in_lists {
|
if !role.hide_in_lists && role.cluster.is_none() {
|
||||||
ActivityBuilder::new(&format!(
|
ActivityBuilder::new(&format!(
|
||||||
"{updated_by} hat die Rolle '{role}' dem Benutzer {self} hinzugefügt."
|
"{updated_by} hat die Rolle '{role}' dem Benutzer {self} hinzugefügt."
|
||||||
))
|
))
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
use std::{fmt::Display, ops::DerefMut};
|
use std::{fmt::Display, ops::DerefMut};
|
||||||
|
|
||||||
use argon2::{Argon2, PasswordHasher, password_hash::SaltString};
|
use argon2::{password_hash::SaltString, Argon2, PasswordHasher};
|
||||||
use chrono::{Datelike, Local, NaiveDate};
|
use chrono::{Datelike, Local, NaiveDate};
|
||||||
use log::info;
|
use log::info;
|
||||||
use rocket::async_trait;
|
use rocket::async_trait;
|
||||||
use rocket::{
|
use rocket::{
|
||||||
Request,
|
|
||||||
http::{Cookie, Status},
|
http::{Cookie, Status},
|
||||||
request::{FromRequest, Outcome},
|
request::{FromRequest, Outcome},
|
||||||
time::{Duration, OffsetDateTime},
|
time::{Duration, OffsetDateTime},
|
||||||
|
Request,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
||||||
|
|
||||||
use super::activity::ActivityBuilder;
|
use super::activity::ActivityBuilder;
|
||||||
use super::{
|
use super::{
|
||||||
Day,
|
|
||||||
log::Log,
|
log::Log,
|
||||||
logbook::Logbook,
|
logbook::Logbook,
|
||||||
mail::Mail,
|
mail::Mail,
|
||||||
@ -24,6 +23,7 @@ use super::{
|
|||||||
role::Role,
|
role::Role,
|
||||||
stat::Stat,
|
stat::Stat,
|
||||||
tripdetails::TripDetails,
|
tripdetails::TripDetails,
|
||||||
|
Day,
|
||||||
};
|
};
|
||||||
use crate::AMOUNT_DAYS_TO_SHOW_TRIPS_AHEAD;
|
use crate::AMOUNT_DAYS_TO_SHOW_TRIPS_AHEAD;
|
||||||
use scheckbuch::ScheckbuchUser;
|
use scheckbuch::ScheckbuchUser;
|
||||||
@ -512,7 +512,7 @@ ASKÖ Ruderverein Donau Linz", self.name),
|
|||||||
.save(db)
|
.save(db)
|
||||||
.await;
|
.await;
|
||||||
return Err(LoginError::InvalidAuthenticationCombo); //User existed sometime ago; has
|
return Err(LoginError::InvalidAuthenticationCombo); //User existed sometime ago; has
|
||||||
//been deleted
|
//been deleted
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(user_pw) = user.pw.as_ref() {
|
if let Some(user_pw) = user.pw.as_ref() {
|
||||||
@ -622,9 +622,9 @@ ASKÖ Ruderverein Donau Linz", self.name),
|
|||||||
pub(crate) async fn amount_days_to_show(&self, db: &SqlitePool) -> i64 {
|
pub(crate) async fn amount_days_to_show(&self, db: &SqlitePool) -> i64 {
|
||||||
if self.allowed_to_steer(db).await {
|
if self.allowed_to_steer(db).await {
|
||||||
let end_of_year = NaiveDate::from_ymd_opt(Local::now().year(), 12, 31).unwrap(); //Ok,
|
let end_of_year = NaiveDate::from_ymd_opt(Local::now().year(), 12, 31).unwrap(); //Ok,
|
||||||
//december
|
//december
|
||||||
//has 31
|
//has 31
|
||||||
//days
|
//days
|
||||||
let days_left_in_year = end_of_year
|
let days_left_in_year = end_of_year
|
||||||
.signed_duration_since(Local::now().date_naive())
|
.signed_duration_since(Local::now().date_naive())
|
||||||
.num_days()
|
.num_days()
|
||||||
@ -633,9 +633,9 @@ ASKÖ Ruderverein Donau Linz", self.name),
|
|||||||
if days_left_in_year <= 31 {
|
if days_left_in_year <= 31 {
|
||||||
let end_of_next_year =
|
let end_of_next_year =
|
||||||
NaiveDate::from_ymd_opt(Local::now().year() + 1, 12, 31).unwrap(); //Ok,
|
NaiveDate::from_ymd_opt(Local::now().year() + 1, 12, 31).unwrap(); //Ok,
|
||||||
//december
|
//december
|
||||||
//has 31
|
//has 31
|
||||||
//days
|
//days
|
||||||
end_of_next_year
|
end_of_next_year
|
||||||
.signed_duration_since(Local::now().date_naive())
|
.signed_duration_since(Local::now().date_naive())
|
||||||
.num_days()
|
.num_days()
|
||||||
@ -867,8 +867,8 @@ special_user!(SteeringUser, +"cox", +"Bootsführer");
|
|||||||
special_user!(AdminUser, +"admin");
|
special_user!(AdminUser, +"admin");
|
||||||
special_user!(AllowedForPlannedTripsUser, +"Donau Linz", +"scheckbuch", +"Förderndes Mitglied");
|
special_user!(AllowedForPlannedTripsUser, +"Donau Linz", +"scheckbuch", +"Förderndes Mitglied");
|
||||||
special_user!(DonauLinzUser, +"Donau Linz", -"Unterstützend", -"Förderndes Mitglied"); // TODO:
|
special_user!(DonauLinzUser, +"Donau Linz", -"Unterstützend", -"Förderndes Mitglied"); // TODO:
|
||||||
// remove ->
|
// remove ->
|
||||||
// RegularUser
|
// RegularUser
|
||||||
special_user!(SchnupperBetreuerUser, +"schnupper-betreuer");
|
special_user!(SchnupperBetreuerUser, +"schnupper-betreuer");
|
||||||
special_user!(VorstandUser, +"admin", +"Vorstand");
|
special_user!(VorstandUser, +"admin", +"Vorstand");
|
||||||
special_user!(EventUser, +"manage_events");
|
special_user!(EventUser, +"manage_events");
|
||||||
@ -982,21 +982,17 @@ mod test {
|
|||||||
#[sqlx::test]
|
#[sqlx::test]
|
||||||
fn wrong_pw() {
|
fn wrong_pw() {
|
||||||
let pool = testdb!();
|
let pool = testdb!();
|
||||||
assert!(
|
assert!(User::login(&pool, "admin".into(), "admi".into())
|
||||||
User::login(&pool, "admin".into(), "admi".into())
|
.await
|
||||||
.await
|
.is_err());
|
||||||
.is_err()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[sqlx::test]
|
#[sqlx::test]
|
||||||
fn wrong_username() {
|
fn wrong_username() {
|
||||||
let pool = testdb!();
|
let pool = testdb!();
|
||||||
assert!(
|
assert!(User::login(&pool, "admi".into(), "admin".into())
|
||||||
User::login(&pool, "admi".into(), "admin".into())
|
.await
|
||||||
.await
|
.is_err());
|
||||||
.is_err()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[sqlx::test]
|
#[sqlx::test]
|
||||||
@ -1015,11 +1011,9 @@ mod test {
|
|||||||
let pool = testdb!();
|
let pool = testdb!();
|
||||||
let user = User::find_by_id(&pool, 1).await.unwrap();
|
let user = User::find_by_id(&pool, 1).await.unwrap();
|
||||||
|
|
||||||
assert!(
|
assert!(User::login(&pool, "admin".into(), "abc".into())
|
||||||
User::login(&pool, "admin".into(), "abc".into())
|
.await
|
||||||
.await
|
.is_err());
|
||||||
.is_err()
|
|
||||||
);
|
|
||||||
|
|
||||||
user.update_pw(&pool, "abc".into()).await;
|
user.update_pw(&pool, "abc".into()).await;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user