Commit 708cd26a authored by Daniel Brüning's avatar Daniel Brüning
Browse files

changed location if hash-function to functions.rs

parent 8db05ea3
......@@ -18,15 +18,6 @@ use self::bcrypt::{DEFAULT_COST, hash, verify, BcryptError};
use ::functions; // todo: remove (usertype in db)
fn hash_password(password: &str, salt: &str) -> Result<String, BcryptError> {
let password_and_salt = [password, salt].concat().to_string();
match hash(password_and_salt, 5) {
Ok(result) => Ok(result),
Err(e) => Err(e)
}
}
fn verify_password(password: &str, salt: &str, password_hash: &str) -> bool {
let password_and_salt = [password, salt].concat().to_string();
match verify(password_and_salt, password_hash) {
......
extern crate bcrypt;
use webfw_iron::{to_json, json_val};
use time;
......@@ -8,6 +10,8 @@ use db_conn::{MedalConnection};
use db_objects::{Submission, Group};
use self::bcrypt::{DEFAULT_COST, hash, verify, BcryptError};
pub fn blaa() -> (String, json_val::Map<String, json_val::Value>) {
let mut data = json_val::Map::new();
......@@ -497,6 +501,13 @@ pub fn show_profile<T: MedalConnection>(conn: &T, session_token: String, user_id
Ok(("profile".to_string(), data))
}
fn hash_password(password: &str, salt: &str) -> Result<String, BcryptError> {
let password_and_salt = [password, salt].concat().to_string();
match hash(password_and_salt, 5) {
Ok(result) => Ok(result),
Err(e) => Err(e)
}
}
pub fn edit_profile<T: MedalConnection>(conn: &T, session_token: String, user_id: Option<u32>, csrf_token: String, firstname: String, lastname: String, new_password_1: String, new_password_2: String, grade: u8) -> MedalResult<()> {
let mut session = conn.get_session(&session_token).ok_or(MedalError::AccessDenied)?.ensure_alive().ok_or(MedalError::AccessDenied)?; // TODO SessionTimeout
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment