Make Account URL Customisable

This commit is contained in:
BloxerHD 2026-06-23 20:22:57 +01:00
commit 2c73e04222
Signed by: bloxerhd018
SSH key fingerprint: SHA256:ItSfcfhpXlfkMK3uQSDYW5X3XKm0hbHWQqWcCK57px8
2 changed files with 3 additions and 1 deletions

View file

@ -4,5 +4,6 @@ APP_PORT=80
# Account Client and Secret # Account Client and Secret
# Token generation will always fail if no secret is specified # Token generation will always fail if no secret is specified
ACCOUNT_URL=https://account.spfn.net
ACCOUNT_CLIENT_ID=account ACCOUNT_CLIENT_ID=account
ACCOUNT_CLIENT_SECRET=secret ACCOUNT_CLIENT_SECRET=secret

View file

@ -35,6 +35,7 @@ pub fn router() -> Router {
async fn gen_token(Json(payload): Json<GenerateTokenRequest>) -> Result<Json<TokenResponse>, StatusCode> { async fn gen_token(Json(payload): Json<GenerateTokenRequest>) -> Result<Json<TokenResponse>, StatusCode> {
let client = Client::new(); let client = Client::new();
let account_url = env::var("ACCOUNT_URL").unwrap_or("https://account.spfn.net".into());
let client_id = env::var("ACCOUNT_CLIENT_ID").unwrap_or("account".into()); let client_id = env::var("ACCOUNT_CLIENT_ID").unwrap_or("account".into());
let client_secret = match env::var("ACCOUNT_CLIENT_SECRET") { let client_secret = match env::var("ACCOUNT_CLIENT_SECRET") {
Ok(secret) => secret, Ok(secret) => secret,
@ -53,7 +54,7 @@ async fn gen_token(Json(payload): Json<GenerateTokenRequest>) -> Result<Json<Tok
}; };
let response = client let response = client
.post(format!("{}/api/v2/oauth2/generate_token", "https://account.spfn.net")) .post(format!("{}/api/v2/oauth2/generate_token", account_url))
.form(&body) .form(&body)
.send() .send()
.await; .await;