fix: should allow folks to register
This commit is contained in:
parent
f60345493c
commit
9db8a238d2
7 changed files with 136 additions and 217 deletions
72
src/lib.rs
72
src/lib.rs
|
@ -1,4 +1,5 @@
|
|||
pub mod methods;
|
||||
|
||||
use chrono::{Datelike, SecondsFormat, Utc};
|
||||
use dotenvy::dotenv;
|
||||
use ldap3::{LdapConn, Mod};
|
||||
|
@ -17,7 +18,6 @@ use tide::prelude::*;
|
|||
#[derive(Debug, Deserialize, Serialize, sqlx::FromRow)]
|
||||
pub struct AccountWolves {
|
||||
pub id_wolves: String,
|
||||
pub id_member: String,
|
||||
pub id_student: Option<String>,
|
||||
pub email: String,
|
||||
pub expiry: String,
|
||||
|
@ -71,29 +71,27 @@ pub async fn db_init(config: &Config) -> Result<Pool<Sqlite>, Error> {
|
|||
|
||||
sqlx::query(
|
||||
"CREATE TABLE IF NOT EXISTS accounts_wolves (
|
||||
id_wolves text DEFAULT '',
|
||||
id_member text DEFAULT '',
|
||||
id_student text,
|
||||
email text not null,
|
||||
expiry text not null,
|
||||
name_first text,
|
||||
name_second text,
|
||||
PRIMARY KEY (id_wolves, id_member)
|
||||
)",
|
||||
id_wolves text PRIMARY KEY,
|
||||
id_student text,
|
||||
email text NOT NULL,
|
||||
expiry text NOT NULL,
|
||||
name_first text,
|
||||
name_second text
|
||||
)",
|
||||
)
|
||||
.execute(&pool)
|
||||
.await?;
|
||||
|
||||
sqlx::query(
|
||||
"CREATE TABLE IF NOT EXISTS accounts_new (
|
||||
mail text primary key,
|
||||
auth_code text not null,
|
||||
date_iso text not null,
|
||||
date_expiry text not null,
|
||||
name_first text not null,
|
||||
name_surname integer not null,
|
||||
id_student text not null
|
||||
)",
|
||||
mail text PRIMARY KEY,
|
||||
auth_code text NOT NULL,
|
||||
date_iso text NOT NULL,
|
||||
date_expiry text NOT NULL,
|
||||
name_first text NOT NULL,
|
||||
name_surname integer NOT NULL,
|
||||
id_student text NOT NULL
|
||||
)",
|
||||
)
|
||||
.execute(&pool)
|
||||
.await?;
|
||||
|
@ -107,20 +105,20 @@ pub async fn db_init(config: &Config) -> Result<Pool<Sqlite>, Error> {
|
|||
|
||||
sqlx::query(
|
||||
"CREATE TABLE IF NOT EXISTS accounts_ssh (
|
||||
user text primary key,
|
||||
auth_code text not null,
|
||||
email text not null
|
||||
)",
|
||||
user text PRIMARY KEY,
|
||||
auth_code text NOT NULL,
|
||||
email text NOT NULL
|
||||
)",
|
||||
)
|
||||
.execute(&pool)
|
||||
.await?;
|
||||
|
||||
sqlx::query(
|
||||
"CREATE TABLE IF NOT EXISTS accounts_reset (
|
||||
user text primary key,
|
||||
auth_code text not null,
|
||||
date_expiry text not null
|
||||
)",
|
||||
user text PRIMARY KEY,
|
||||
auth_code text NOT NULL,
|
||||
date_expiry text NOT NULL
|
||||
)",
|
||||
)
|
||||
.execute(&pool)
|
||||
.await?;
|
||||
|
@ -135,14 +133,14 @@ pub async fn db_init(config: &Config) -> Result<Pool<Sqlite>, Error> {
|
|||
// this is for active use
|
||||
sqlx::query(
|
||||
"CREATE TABLE IF NOT EXISTS accounts (
|
||||
user text primary key,
|
||||
uid integer not null,
|
||||
discord text,
|
||||
mail text not null,
|
||||
student_id text not null,
|
||||
enabled integer not null,
|
||||
secure integer not null
|
||||
)",
|
||||
user text PRIMARY KEY,
|
||||
uid integer NOT NULL,
|
||||
discord text,
|
||||
mail text NOT NULL,
|
||||
student_id text NOT NULL,
|
||||
enabled integer NOT NULL,
|
||||
secure integer NOT NULL
|
||||
)",
|
||||
)
|
||||
.execute(&pool)
|
||||
.await?;
|
||||
|
@ -271,9 +269,9 @@ pub fn random_string(len: usize) -> String {
|
|||
pub async fn get_wolves(db: &Pool<Sqlite>) -> Vec<AccountWolves> {
|
||||
sqlx::query_as::<_, AccountWolves>(
|
||||
r#"
|
||||
SELECT *
|
||||
FROM accounts_wolves
|
||||
"#,
|
||||
SELECT *
|
||||
FROM accounts_wolves
|
||||
"#,
|
||||
)
|
||||
.fetch_all(db)
|
||||
.await
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue