Remove user authentication and switch to simple admin password check (It wont have more than one admin user so no need for registeration (I LOVE .Net/C# btw))

This commit is contained in:
2025-05-15 20:25:28 +03:30
parent d646515776
commit 49b38470cf
7 changed files with 14 additions and 79 deletions

View File

@@ -3,6 +3,7 @@ package helpers
import (
"CatsOfMastodonBotGo/internal"
"CatsOfMastodonBotGo/internal/services"
"log"
"os"
"gorm.io/driver/sqlite"
@@ -12,14 +13,19 @@ import (
func SetupAppContext() *internal.AppContext {
// Setup AppContext
instance := os.Getenv("INSTANCE")
instance := os.Getenv("CAOM_INSTANCE")
if instance == "" {
instance = "https://mstdn.party"
}
tag := os.Getenv("TAG")
tag := os.Getenv("CAOM_TAG")
if tag == "" {
tag = "catsofmastodon"
}
adminPassword := os.Getenv("CAOM_ADMIN_PASSWORD")
if adminPassword == "" {
log.Println("No admin password provided, using default password 'catsaregood'")
adminPassword = "catsaregood"
}
// Setup database
db, err := gorm.Open(sqlite.Open("test.db"), &gorm.Config{Logger: logger.Default.LogMode(logger.Warn)})
@@ -31,14 +37,10 @@ func SetupAppContext() *internal.AppContext {
//Setup PostService
var postService = services.NewPostService(db)
// Setup UserService
var userService = services.NewUserService(db)
// Inititlize AppContext
var appContext = &internal.AppContext{
Db: db,
PostService: postService,
UserService: userService,
Instance: instance,
Tag: tag,
}