diff --git a/backend/db/db.sqlite3-shm b/backend/db/db.sqlite3-shm new file mode 100644 index 0000000..c2ea797 Binary files /dev/null and b/backend/db/db.sqlite3-shm differ diff --git a/backend/db/db.sqlite3-wal b/backend/db/db.sqlite3-wal new file mode 100644 index 0000000..1cb50c0 Binary files /dev/null and b/backend/db/db.sqlite3-wal differ diff --git a/backend/src/google_oauth.rs b/backend/src/google_oauth.rs index 72994e6..b739bb6 100644 --- a/backend/src/google_oauth.rs +++ b/backend/src/google_oauth.rs @@ -1,10 +1,8 @@ -use axum_session::{Session, SessionAnyPool}; -use axum::{ - extract::Query, - response::{IntoResponse, Redirect}, -}; +use axum:: + response::{IntoResponse, Redirect} +; use oauth2::{ - basic::BasicClient, reqwest::async_http_client, AuthUrl, AuthorizationCode, ClientId, ClientSecret, CsrfToken, PkceCodeChallenge, RedirectUrl, Scope, TokenResponse, TokenUrl + basic::BasicClient, AuthUrl, ClientId, ClientSecret, CsrfToken, PkceCodeChallenge, RedirectUrl, Scope, TokenUrl }; use serde::Deserialize; use std::env; @@ -35,53 +33,6 @@ pub async fn google_auth() -> impl IntoResponse { Redirect::to(&auth_url.to_string()) } -pub async fn google_authorized(_session: Session, - Query(query): Query, - // Extension(oauth_clients): Extension>, -) -> impl IntoResponse { - // Check for Google client - // if oauth_clients.contains_key("Google") { - - println!("{:?}", query); - - // Get an auth token - let token = match google_oauth_client() - .exchange_code(AuthorizationCode::new(query.code.clone())) - .request_async(async_http_client) - .await { - Ok(token) => token, - Err(_) => panic!("Didn't get a token"), - }; - /* - // Fetch user data from google - let client = reqwest::Client::new(); - let user_data: User = client - // https://discord.com/developers/docs/resources/user#get-current-user - .get("https://discordapp.com/api/users/@me") - .bearer_auth(token.access_token().secret()) - .send() - .await - .unwrap() - .json::() - .await - .unwrap(); - */ - - //(headers, Redirect::to("/dashboard".parse().unwrap())) - // } - - let mut page = String::new(); - page.push_str(&"Display the data returned by Google\n".to_string()); - page.push_str(&"\nState: ".to_string()); - page.push_str(&query.state); - page.push_str(&"\nCode: ".to_string()); - page.push_str(&query.code); - page.push_str(&"\nAccess Token: ".to_string()); - page.push_str(&token.access_token().secret()); - - page -} - pub fn google_oauth_client() -> BasicClient { if std::env::var_os("GOOGLE_CLIENT_ID").is_none() { std::env::set_var("GOOGLE_CLIENT_ID", "735264084619-clsmvgdqdmum4rvrcj0kuk28k9agir1c.apps.googleusercontent.com") diff --git a/backend/src/main.rs b/backend/src/main.rs index 69596c5..ba08fdf 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -1,10 +1,8 @@ use std::net::SocketAddr; use askama::Template; use axum::{ - extract::{FromRef, State}, middleware, response::{Html, IntoResponse, Redirect, Response}, routing::{get, get_service}, Extension, Router + middleware, response::{Html, IntoResponse, Response}, routing::{get, get_service}, Extension, Router }; -use axum_extra::TypedHeader; -use headers::Cookie; use http::{Request, StatusCode}; use sqlx::{sqlite::SqlitePoolOptions, SqlitePool}; use tower_http::services::ServeDir; @@ -44,13 +42,6 @@ struct IndexTemplate { name: String, } -#[derive(Template)] -#[template(path = "login.html")] -struct LoginTemplate { - logged_in: bool, - name: String, -} - #[derive(Clone)] pub struct AppState { pub db_pool: SqlitePool, @@ -109,10 +100,9 @@ async fn main() { async fn index( Extension(user_data): Extension>, - request: Request, + _request: Request, ) -> impl IntoResponse { let user_email = user_data.map(|s| s.user_email); - let login_return_url = "?return_url=".to_owned() + &*request.uri().to_string(); let logged_in = user_email.is_some(); let name = user_email.unwrap_or_default(); diff --git a/backend/templates/anonymous.html b/backend/templates/anonymous.html new file mode 100644 index 0000000..70f38cb --- /dev/null +++ b/backend/templates/anonymous.html @@ -0,0 +1,44 @@ + + -{% endblock content %} \ No newline at end of file diff --git a/backend/templates/index.html b/backend/templates/index.html index 87c9d82..d07128b 100644 --- a/backend/templates/index.html +++ b/backend/templates/index.html @@ -1,46 +1,66 @@ {% extends "base.html" %} {% block content %} +{% if logged_in %} +
+
+

This will be the private information area for the extended Jean-Marie family.

+
+

Web links

+

Fonts

+ +

Family tree

+ +
+
+{% else %}