userland invites endpoint now uses db::members::add as its intended
This commit is contained in:
parent
f0f0272c32
commit
c6d8e3d360
@ -12,7 +12,8 @@ use chrono::Utc;
|
|||||||
|
|
||||||
use db::{UBigInt, BigInt};
|
use db::{UBigInt, BigInt};
|
||||||
use db::common::FromDB;
|
use db::common::FromDB;
|
||||||
use crate::members::{self, Member};
|
use db::member::Member;
|
||||||
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct Invite {
|
struct Invite {
|
||||||
@ -60,15 +61,24 @@ async fn use_invite(pool: &Pool, code: Option<BigInt>) -> Option<Member>{
|
|||||||
/*
|
/*
|
||||||
* Attempts to change the state of the current invite being provided
|
* Attempts to change the state of the current invite being provided
|
||||||
*/
|
*/
|
||||||
|
use crate::auth;
|
||||||
use crate::perms::GENERAL_NEW;
|
use crate::perms::GENERAL_NEW;
|
||||||
let id = match code {
|
let id = match code {
|
||||||
Some(id) => id,
|
Some(id) => id,
|
||||||
None => 0
|
None => 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// some random comment
|
||||||
if valid_invite(pool, id).await {
|
if valid_invite(pool, id).await {
|
||||||
match members::insert_new_member(pool, "Anonymous".into(), GENERAL_NEW).await {
|
let secret = auth::generate_secret();
|
||||||
Ok(member) => return Some(member),
|
return match db::member::Member::add(pool, "Anonymous".into(), &secret, GENERAL_NEW).await {
|
||||||
|
Ok(response) => {
|
||||||
|
match response {
|
||||||
|
db::Response::Row(member) => Some(member),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// TODO: logggin or something idk
|
||||||
Err(_) => return None
|
Err(_) => return None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,7 +95,6 @@ pub async fn join(pool: &Pool, response: &mut Response<Body>, params: Value) {
|
|||||||
Some(val) => val.as_i64(),
|
Some(val) => val.as_i64(),
|
||||||
None => None
|
None => None
|
||||||
};
|
};
|
||||||
|
|
||||||
match use_invite(&pool, code).await {
|
match use_invite(&pool, code).await {
|
||||||
Some(new_account) => *response.body_mut() = Body::from(serde_json::to_string(&new_account).unwrap()),
|
Some(new_account) => *response.body_mut() = Body::from(serde_json::to_string(&new_account).unwrap()),
|
||||||
None => {
|
None => {
|
||||||
|
Loading…
Reference in New Issue
Block a user