forked from spacebar/spfn-website
Make Account URL Customisable
This commit is contained in:
parent
91882fe4ae
commit
2c73e04222
2 changed files with 3 additions and 1 deletions
|
|
@ -4,5 +4,6 @@ APP_PORT=80
|
|||
|
||||
# Account Client and Secret
|
||||
# Token generation will always fail if no secret is specified
|
||||
ACCOUNT_URL=https://account.spfn.net
|
||||
ACCOUNT_CLIENT_ID=account
|
||||
ACCOUNT_CLIENT_SECRET=secret
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ pub fn router() -> Router {
|
|||
async fn gen_token(Json(payload): Json<GenerateTokenRequest>) -> Result<Json<TokenResponse>, StatusCode> {
|
||||
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_secret = match env::var("ACCOUNT_CLIENT_SECRET") {
|
||||
Ok(secret) => secret,
|
||||
|
|
@ -53,7 +54,7 @@ async fn gen_token(Json(payload): Json<GenerateTokenRequest>) -> Result<Json<Tok
|
|||
};
|
||||
|
||||
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)
|
||||
.send()
|
||||
.await;
|
||||
|
|
|
|||
Loading…
Reference in a new issue