user: add a route to fetch by ID

Signed-off-by: ATechnoHazard <amolele@gmail.com>
This commit is contained in:
sphericalkat committed 2020-09-26 15:43:59 +05:30
1 parent 97f66956ba
commit beaca24246
2 files changed
+14 -4

No files matched your search

+4
View File
@@ -33,6 +33,10 @@ pub fn create_or_fetch_user(id: String, conn: &PgConnection) -> Result<User> {
Ok(user)
}
pub fn fetch_user(id: String, conn: &PgConnection) -> Result<User> {
postgres::find_user(id, conn)
}
pub fn activate_user(user: &mut User, conn: &PgConnection) -> Result<User> {
let hashed_pass = hash(user.password.as_ref().unwrap().as_bytes(), DEFAULT_COST)?;
user.password = Some(hashed_pass);