add: profile connections, spotify connection

This commit is contained in:
trisua 2025-04-26 16:27:18 -04:00
parent a5c2356940
commit 33ba576d4a
31 changed files with 931 additions and 19 deletions

View file

@ -1,9 +1,13 @@
use crate::{State, assets::initial_context, get_lang, get_user_from_token};
use axum::{
Extension,
extract::Path,
response::{Html, IntoResponse},
Extension,
};
use axum_extra::extract::CookieJar;
use tetratto_core::model::{Error, auth::ConnectionService};
use super::render_error;
/// `/auth/login`
pub async fn login_request(jar: CookieJar, Extension(data): Extension<State>) -> impl IntoResponse {
@ -37,3 +41,22 @@ pub async fn register_request(
Html(data.1.render("auth/register.html", &context).unwrap())
}
/// `/auth/connections_link/{service}`
pub async fn connection_callback_request(
jar: CookieJar,
Extension(data): Extension<State>,
Path(service): Path<ConnectionService>,
) -> impl IntoResponse {
let data = data.read().await;
let user = match get_user_from_token!(jar, data.0) {
Some(ua) => ua,
None => return Html(render_error(Error::NotAllowed, &jar, &data, &None).await),
};
let lang = get_lang!(jar, data.0);
let mut context = initial_context(&data.0.0, lang, &Some(user)).await;
context.insert("connection_type", &service);
Html(data.1.render("auth/connection.html", &context).unwrap())
}

View file

@ -53,6 +53,10 @@ pub fn routes() -> Router {
// auth
.route("/auth/register", get(auth::register_request))
.route("/auth/login", get(auth::login_request))
.route(
"/auth/connections_link/{service}",
get(auth::connection_callback_request),
)
// profile
.route("/settings", get(profile::settings_request))
.route("/@{username}", get(profile::posts_request))