migrate from envars to toml config

This commit is contained in:
ari melody 2024-11-10 05:34:04 +00:00
parent 5284b8a7cc
commit 04f7f97b62
Signed by: ari
GPG key ID: CF99829C92678188
12 changed files with 182 additions and 109 deletions

View file

@ -6,7 +6,6 @@ import (
"fmt"
"net/http"
"net/url"
"os"
"strings"
"arimelody-web/global"
@ -16,22 +15,22 @@ const API_ENDPOINT = "https://discord.com/api/v10"
var CREDENTIALS_PROVIDED = true
var CLIENT_ID = func() string {
id := os.Getenv("DISCORD_CLIENT")
id := global.Config.Discord.ClientID
if id == "" {
fmt.Printf("WARN: Discord client ID (DISCORD_CLIENT) was not provided. Admin login will be unavailable.\n")
fmt.Printf("WARN: discord.client_id was not provided. Admin login will be unavailable.\n")
CREDENTIALS_PROVIDED = false
}
return id
}()
var CLIENT_SECRET = func() string {
secret := os.Getenv("DISCORD_SECRET")
secret := global.Config.Discord.Secret
if secret == "" {
fmt.Printf("WARN: Discord secret (DISCORD_SECRET) was not provided. Admin login will be unavailable.\n")
fmt.Printf("WARN: discord.secret not provided. Admin login will be unavailable.\n")
CREDENTIALS_PROVIDED = false
}
return secret
}()
var OAUTH_CALLBACK_URI = fmt.Sprintf("%s/admin/login", global.HTTP_DOMAIN)
var OAUTH_CALLBACK_URI = fmt.Sprintf("%s/admin/login", global.Config.BaseUrl)
var REDIRECT_URI = fmt.Sprintf("https://discord.com/oauth2/authorize?client_id=%s&response_type=code&redirect_uri=%s&scope=identify", CLIENT_ID, OAUTH_CALLBACK_URI)
type (