feat: now check local db for pending usernames
This commit is contained in:
parent
894b6d42e5
commit
e83adea4fe
2 changed files with 54 additions and 12 deletions
30
src/lib.rs
30
src/lib.rs
|
@ -5,6 +5,19 @@ use sqlx::{Error, Pool, Sqlite};
|
|||
use std::env;
|
||||
use std::str::FromStr;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
use tide::prelude::*;
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, sqlx::FromRow)]
|
||||
pub struct AccountsPending {
|
||||
user: String,
|
||||
mail: String,
|
||||
name_first : String,
|
||||
name_second : String,
|
||||
auth_code : String,
|
||||
discord: Option<String>,
|
||||
// will only last for a few hours
|
||||
expiry: i64
|
||||
}
|
||||
|
||||
pub async fn db_init(database: &str) -> Result<Pool<Sqlite>, Error> {
|
||||
let pool = SqlitePoolOptions::new()
|
||||
|
@ -12,21 +25,20 @@ pub async fn db_init(database: &str) -> Result<Pool<Sqlite>, Error> {
|
|||
.connect_with(SqliteConnectOptions::from_str(&format!("sqlite://{}", database))?.create_if_missing(true))
|
||||
.await?;
|
||||
|
||||
/*
|
||||
// https://store.steampowered.com/api/appdetails?appids=1258740
|
||||
sqlx::query(
|
||||
"CREATE TABLE IF NOT EXISTS store_details (
|
||||
id integer primary key,
|
||||
name text not null,
|
||||
item_type text not null,
|
||||
last_timestamp integer not null
|
||||
"CREATE TABLE IF NOT EXISTS accounts_pending (
|
||||
user text primary key,
|
||||
mail text not null,
|
||||
name_first text not null,
|
||||
name_second text not null,
|
||||
auth_code text not null,
|
||||
discord text,
|
||||
expiry integer not null
|
||||
)",
|
||||
)
|
||||
.execute(&pool)
|
||||
.await?;
|
||||
|
||||
*/
|
||||
|
||||
// set up indexes?
|
||||
/*
|
||||
sqlx::query("CREATE INDEX IF NOT EXISTS index_estimate ON bus_results (valid_estimate)")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue