Fix logging

This commit is contained in:
Dietrich 2021-02-08 14:11:33 +01:00
parent a71ba86e45
commit a99e20d1e6
Signed by: dietrich
GPG Key ID: 9F3C20C0F85DF67C
3 changed files with 7 additions and 8 deletions

View File

@ -90,7 +90,7 @@ async fn main() -> std::io::Result<()> {
dotenv().ok();
env_logger::init();
println!("Running on: http://127.0.0.1:8156");
println!("Running on: http://127.0.0.1:8156/admin/login/");
HttpServer::new(|| {
let tera = Tera::new("templates/**/*").expect("failed to initialize the templates");
let generated = generate();

View File

@ -1,7 +1,7 @@
use crate::{forms::LinkForm, ServerError};
use super::schema::{links, users};
use argonautica::{Hasher, Verifier};
use argonautica::Hasher;
use diesel::{Insertable, Queryable};
use dotenv::dotenv;
use serde::{Deserialize, Serialize};

View File

@ -113,7 +113,7 @@ pub(crate) async fn view_profile(
user_id: web::Path<String>,
) -> Result<HttpResponse, ServerError> {
use super::schema::users::dsl::{id, users};
println!("Viewing Profile!");
info!("Viewing Profile!");
if let Some(identity) = identity.identity() {
let connection = establish_connection()?;
if let Ok(uid) = user_id.parse::<i32>() {
@ -146,7 +146,7 @@ pub(crate) async fn edit_profile(
user_id: web::Path<String>,
) -> Result<HttpResponse, ServerError> {
use super::schema::users::dsl::{id, users};
println!("Viewing Profile!");
info!("Editing Profile!");
if let Some(identity) = identity.identity() {
let connection = establish_connection()?;
if let Ok(uid) = user_id.parse::<i32>() {
@ -182,7 +182,7 @@ pub(crate) async fn process_edit_profile(
use super::schema::users::dsl::{email, id, password, username, users};
if let Ok(uid) = user_id.parse::<i32>() {
println!("Updating userinfo: ");
info!("Updating userinfo: ");
let connection = establish_connection()?;
diesel::update(users.filter(id.eq(uid)))
.set((
@ -267,7 +267,6 @@ pub(crate) async fn process_signup(
.values(&new_user)
.execute(&connection)?;
println!("{:?}", data);
Ok(HttpResponse::Ok().body(format!("Successfully saved user: {}", data.username)))
} else {
Ok(redirect_builder("/admin/login/"))
@ -311,7 +310,7 @@ pub(crate) async fn process_login(
.verify()?;
if valid {
println!("Login of user: {}", &u.username);
info!("Log-in of user: {}", &u.username);
let session_token = u.username;
id.remember(session_token);
Ok(redirect_builder("/admin/index/"))
@ -320,7 +319,7 @@ pub(crate) async fn process_login(
}
}
Err(e) => {
println!("Failed to login: {}", e);
info!("Failed to login: {}", e);
Ok(redirect_builder("/admin/login/"))
}
}