1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-29 22:01:14 +03:00

Split the mutations and make them use an input object instead of different parameters

This commit is contained in:
Quentin Gliech
2023-04-21 15:03:57 +02:00
parent c2d8243586
commit 047a91907d
6 changed files with 164 additions and 61 deletions

View File

@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use std::ops::Deref;
use chrono::{DateTime, Duration, Utc};
use rand::{Rng, SeedableRng};
use serde::Serialize;
@ -131,6 +133,13 @@ pub enum UserEmailVerificationState {
Valid,
}
impl UserEmailVerificationState {
#[must_use]
pub fn is_valid(&self) -> bool {
matches!(self, Self::Valid)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct UserEmailVerification {
pub id: Ulid,
@ -140,6 +149,14 @@ pub struct UserEmailVerification {
pub state: UserEmailVerificationState,
}
impl Deref for UserEmailVerification {
type Target = UserEmailVerificationState;
fn deref(&self) -> &Self::Target {
&self.state
}
}
impl UserEmailVerification {
#[must_use]
pub fn samples(now: chrono::DateTime<Utc>, rng: &mut impl Rng) -> Vec<Self> {