update user.rs file
This commit is contained in:
@@ -1,16 +1,24 @@
|
|||||||
use sqlite::Connection;
|
use sqlite::Connection;
|
||||||
use sqlite::State;
|
// use sodiumoxide::crypto::secretbox;
|
||||||
|
|
||||||
pub struct User {
|
pub struct User {
|
||||||
name: String,
|
name: String,
|
||||||
level: u32,
|
level: u32,
|
||||||
password: String,
|
// password: [u8],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl User {
|
impl User {
|
||||||
pub fn open(name: String, level: u32, password: String) -> User {
|
pub fn open(name: String, level: u32, password: [u8]) -> User {
|
||||||
User {name, level, password}
|
User {name, level, password}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_name(&self) -> String{return self.name.clone()}
|
||||||
|
pub fn get_level(&self) -> u32{return self.level}
|
||||||
|
// pub fn get_password(&self) -> [u8]{return self.password.clone()}
|
||||||
|
|
||||||
|
// pub fn check_password(&self,nonce:secretbox::Nonce,key:secretbox::Key){
|
||||||
|
// assert!("" == secretbox::open(self.get_password(), &nonce, &key).unwrap()[..]);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -45,11 +53,9 @@ impl DataBase {
|
|||||||
|
|
||||||
pub fn check(&self, table: &str, arg: &str) -> bool {
|
pub fn check(&self, table: &str, arg: &str) -> bool {
|
||||||
let mut end = false;
|
let mut end = false;
|
||||||
self.connection.iterate("Select name FROM ".to_owned() + &table.to_string() + " WHERE name = " + &arg.to_string(), |pairs| {
|
self.connection.iterate("Select name FROM ".to_owned() + &table.to_string() + " WHERE name = " + &format!("'{}'",&arg.to_string()), |pairs| {
|
||||||
for &(name, value) in pairs.iter() {
|
for &(name, value) in pairs.iter() {
|
||||||
println!("{} = {}", name, value.unwrap());
|
|
||||||
if name == "name" {
|
if name == "name" {
|
||||||
println!("True");
|
|
||||||
end = true;
|
end = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user