Add invite creation, removal, fetch and usage.

This commit is contained in:
Paul Makles
2020-04-11 21:48:10 +01:00
parent 1a41a68ee6
commit d1b44a311f
8 changed files with 271 additions and 38 deletions

View File

@@ -1,24 +1,17 @@
use super::Response;
use crate::database;
use crate::email;
use crate::util::gen_token;
use bcrypt::{hash, verify};
use bson::{doc, from_bson, Bson::UtcDatetime};
use chrono::prelude::*;
use database::user::User;
use rand::{distributions::Alphanumeric, Rng};
use rocket_contrib::json::Json;
use serde::{Deserialize, Serialize};
use ulid::Ulid;
use validator::validate_email;
fn gen_token(l: usize) -> String {
rand::thread_rng()
.sample_iter(&Alphanumeric)
.take(l)
.collect::<String>()
}
#[derive(Serialize, Deserialize)]
pub struct Create {
username: String,