29 lines
529 B
Rust
29 lines
529 B
Rust
mod database;
|
|
mod error;
|
|
|
|
use chrono::{DateTime, Utc};
|
|
use id::{AppID, UserID};
|
|
|
|
pub use crate::error::Error;
|
|
|
|
#[derive(Debug)]
|
|
pub struct AuthorizationCode {
|
|
// Info
|
|
code: String,
|
|
app: AppID,
|
|
user: UserID,
|
|
|
|
// Timings
|
|
created_at: DateTime<Utc>,
|
|
expires_at: DateTime<Utc>,
|
|
used_at: Option<DateTime<Utc>>,
|
|
}
|
|
|
|
impl AuthorizationCode {
|
|
pub fn has_been_used(&self) -> bool {
|
|
self.used_at.is_some()
|
|
}
|
|
pub fn has_expired(&self) -> bool {
|
|
self.expires_at < Utc::now()
|
|
}
|
|
}
|