Add finishing touches

This commit is contained in:
Erikas 2024-07-12 23:57:42 +03:00
parent 40328cb228
commit 88469fe6a2
4 changed files with 8 additions and 12 deletions

View File

@ -1,11 +0,0 @@
package main
import "fmt"
/*
This app is a migration tool from v0.0.7 to v0.0.8
*/
func main() {
fmt.Println("Hello, World!")
}

View File

@ -14,6 +14,7 @@ type Config struct {
DiscordClientID string
DiscordClientSecret string
DiscordRedirectURL string
SessionSecret string
Version bool
}
@ -25,6 +26,7 @@ func NewConfig() (*Config, error) {
discordClientID := flag.String("discord-client-id", "", "Discord OAuth2 client ID (see https://discord.com/developers/applications)")
discordClientSecret := flag.String("discord-client-secret", "", "Discord OAuth2 client secret (see https://discord.com/developers/applications)")
discordRedirectURL := flag.String("discord-redirect-url", "", "Discord OAuth2 redirect URL (<scheme>://<domain>/login/callback)")
sessionSecret := flag.String("session-secret", "", "Session secret")
flagVersion := flag.Bool("version", false, "prints version of the application")
envflag.Parse(envflag.WithPrefix("FS_"))
@ -36,6 +38,7 @@ func NewConfig() (*Config, error) {
DiscordClientID: *discordClientID,
DiscordClientSecret: *discordClientSecret,
DiscordRedirectURL: *discordRedirectURL,
SessionSecret: *sessionSecret,
Version: *flagVersion,
}
@ -56,6 +59,9 @@ func NewConfig() (*Config, error) {
if config.DiscordRedirectURL == "" {
return nil, errors.New("missing discord-redirect-url argument")
}
if config.SessionSecret == "" {
return nil, errors.New("missing session-secret argument")
}
return config, nil
}

View File

@ -13,4 +13,5 @@ services:
- FS_DISCORD_CLIENT_ID=xxxxxxxxxxxxxxxxxx
- FS_DISCORD_CLIENT_SECRET=xxxxxxxxxxxxxxxxxx
- FS_DISCORD_REDIRECT_URL=<scheme>://<domain>/login/callback
- FS_SESSION_SECRET=xxxxxxxxxxxxxxxxxx
restart: unless-stopped

View File

@ -66,7 +66,7 @@ func Start(c *Config) {
if err != nil {
panic(err)
}
store := gormsessions.NewStore(db, true, []byte("secret"))
store := gormsessions.NewStore(db, true, []byte(c.SessionSecret))
db.AutoMigrate(&Benchmark{})
// Setup gin //