create_new_user
no longer checks id column when comparing against unix timestamps
This commit is contained in:
parent
383fd59eba
commit
cd41dc64c3
@ -5,7 +5,7 @@ use diesel::{self, prelude::*};
|
||||
use diesel::result::Error;
|
||||
|
||||
use crate::rand_utils::new_key;
|
||||
use crate::models::{User, USER_ONLINE, USER_OFFLINE};
|
||||
use crate::models::{User, USER_OFFLINE};
|
||||
use crate::{DBConn, schema};
|
||||
|
||||
pub fn create_new_user(new_name: String) -> User {
|
||||
@ -20,7 +20,7 @@ pub fn create_new_user(new_name: String) -> User {
|
||||
name: new_name,
|
||||
secret: new_key(),
|
||||
date: Utc::now().timestamp() as u64,
|
||||
status: USER_ONLINE,
|
||||
status: USER_OFFLINE,
|
||||
};
|
||||
// insert the nwe user data then return usable user data to the client
|
||||
let _inserted_user = diesel::insert_into(users)
|
||||
@ -28,10 +28,13 @@ pub fn create_new_user(new_name: String) -> User {
|
||||
.execute(&conn);
|
||||
|
||||
let new_user_data : Result<User, diesel::result::Error> = users
|
||||
.filter(id.eq(ins.date))
|
||||
.filter(date.eq(ins.date))
|
||||
.first(&conn);
|
||||
|
||||
new_user_data.unwrap()
|
||||
match new_user_data {
|
||||
Ok(data) => data,
|
||||
Err(_e) => panic!("User could not be found with date of {}", ins.date)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user