boilerplate for database functionality
This commit is contained in:
parent
91da2ac15f
commit
ba0673540d
58
server/src/db.rs
Normal file
58
server/src/db.rs
Normal file
@ -0,0 +1,58 @@
|
||||
/* Here we maintain all the different structures that we use to
|
||||
* interface with our database at any given time
|
||||
*/
|
||||
|
||||
use diesel::prelude::SqliteConnection;
|
||||
|
||||
enum UserType {
|
||||
Native,
|
||||
Remote,
|
||||
Invalid,
|
||||
}
|
||||
#[table_name="users"]
|
||||
#[derive(Serialize, Queryable, Insertable, Debug, Clone)]
|
||||
struct User {
|
||||
userid: String,
|
||||
/* Sometimes this isn't a password persey
|
||||
* Basically: native users and remote users will share this here but
|
||||
* remote users are given a passkey which they don't control.
|
||||
*/
|
||||
passkey: String,
|
||||
native: bool,
|
||||
display: String,
|
||||
}
|
||||
|
||||
#[derive(FromForm)]
|
||||
struct UserRegister{
|
||||
userid: String,
|
||||
display: String,
|
||||
passkey: String, // basically just a hash for now
|
||||
}
|
||||
|
||||
struct Ticket {
|
||||
hashValue: String // probably just some huge text hash
|
||||
}
|
||||
impl User {
|
||||
|
||||
/* only ever add a user to our database if they have a ticket whose id matches with
|
||||
* a currently valid id
|
||||
* This means that instances can be set to invite only if owners wish
|
||||
*/
|
||||
pub fn insert(user: UserLogin, entry: Ticket, conn: &SqliteConnection) -> bool {
|
||||
}
|
||||
|
||||
pub fn remove(userid: String) -> Result<User> {
|
||||
}
|
||||
|
||||
pub fn get_user(userid: String) -> Result<User> {
|
||||
}
|
||||
|
||||
pub fn update_display(userid: String) -> bool {
|
||||
}
|
||||
|
||||
pub fn update_passkey(userid: String, newpass_hash: String) -> bool {
|
||||
}
|
||||
|
||||
pub fn update_native(userid: String, newdisplay: String) -> bool {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user