From 7d51c8dd07d93e24a161c5e1fca045ed1de22b82 Mon Sep 17 00:00:00 2001 From: Eccentric Date: Tue, 26 Dec 2023 03:18:12 +0000 Subject: [PATCH] remove not needed db tables --- handlers/discord.go | 9 +++++++-- main.go | 2 +- storage/postgres.go | 9 --------- storage/storage.go | 11 ----------- storage/tables.go | 17 +++-------------- 5 files changed, 11 insertions(+), 37 deletions(-) diff --git a/handlers/discord.go b/handlers/discord.go index a2e8ec9..2d1ce1e 100644 --- a/handlers/discord.go +++ b/handlers/discord.go @@ -3,6 +3,7 @@ package handlers import ( "net/http" "net/url" + "time" "github.com/ectrc/snow/aid" p "github.com/ectrc/snow/person" @@ -74,14 +75,18 @@ func GetDiscordOAuthURL(c *fiber.Ctx) error { person.Discord.Banner = user.Banner storage.Repo.SaveDiscordPerson(person.Discord) - access, sig := aid.KeyPair.EncryptAndSignB64([]byte(person.ID + ".frontend")) + access, err := aid.JWTSign(aid.JSON{ + "snow_id": person.ID, // custom + "frontend": true, + "creation_date": time.Now().Format("2006-01-02T15:04:05.999Z"), + }) if err != nil { return c.Status(fiber.StatusInternalServerError).JSON(aid.ErrorInternalServer) } c.Cookie(&fiber.Cookie{ Name: "access_token", - Value: access + "." + sig, + Value: access, }) return c.Redirect(aid.Config.API.Host + aid.Config.API.FrontendPort + "/attempt") } \ No newline at end of file diff --git a/main.go b/main.go index 5d4e2fb..0def37e 100644 --- a/main.go +++ b/main.go @@ -76,7 +76,7 @@ func main() { fortnite := r.Group("/fortnite/api") fortnite.Get("/receipts/v1/account/:accountId/receipts", handlers.GetFortniteReceipts) - fortnite.Get("/v2/versioncheck/*", handlers.GetFortniteVersion) + fortnite.Get("/v2/versioncheck/:version", handlers.GetFortniteVersion) fortnite.Get("/calendar/v1/timeline", handlers.GetFortniteTimeline) storefront := fortnite.Group("/storefront/v2") diff --git a/storage/postgres.go b/storage/postgres.go index a124dee..52f1527 100644 --- a/storage/postgres.go +++ b/storage/postgres.go @@ -43,7 +43,6 @@ func (s *PostgresStorage) MigrateAll() { s.Migrate(&DB_Loot{}, "Loot") s.Migrate(&DB_VariantChannel{}, "Variants") s.Migrate(&DB_PAttribute{}, "Attributes") - s.Migrate(&DB_TemporaryCode{}, "ExchangeCodes") s.Migrate(&DB_DiscordPerson{}, "Discords") s.Migrate(&DB_SeasonStat{}, "Stats") } @@ -227,14 +226,6 @@ func (s *PostgresStorage) DeleteLoadout(loadoutId string) { s.Postgres.Delete(&DB_Loadout{}, "id = ?", loadoutId) } -func (s *PostgresStorage) SaveTemporaryCode(code *DB_TemporaryCode) { - s.Postgres.Save(code) -} - -func (s *PostgresStorage) DeleteTemporaryCode(codeId string) { - s.Postgres.Delete(&DB_TemporaryCode{}, "id = ?", codeId) -} - func (s *PostgresStorage) SaveDiscordPerson(discordPerson *DB_DiscordPerson) { s.Postgres.Save(discordPerson) } diff --git a/storage/storage.go b/storage/storage.go index 52af0e2..cadc021 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -43,9 +43,6 @@ type Storage interface { SaveLoadout(loadout *DB_Loadout) DeleteLoadout(loadoutId string) - SaveTemporaryCode(code *DB_TemporaryCode) - DeleteTemporaryCode(codeId string) - SaveDiscordPerson(person *DB_DiscordPerson) DeleteDiscordPerson(personId string) } @@ -175,14 +172,6 @@ func (r *Repository) DeleteLoadout(loadoutId string) { r.Storage.DeleteLoadout(loadoutId) } -func (r *Repository) SaveTemporaryCode(code *DB_TemporaryCode) { - r.Storage.SaveTemporaryCode(code) -} - -func (r *Repository) DeleteTemporaryCode(codeId string) { - r.Storage.DeleteTemporaryCode(codeId) -} - func (r *Repository) SaveDiscordPerson(person *DB_DiscordPerson) { r.Storage.SaveDiscordPerson(person) } diff --git a/storage/tables.go b/storage/tables.go index fa2ad7a..4793e32 100644 --- a/storage/tables.go +++ b/storage/tables.go @@ -138,17 +138,6 @@ func (DB_Loot) TableName() string { return "Loot" } -type DB_TemporaryCode struct { - ID string `gorm:"primary_key"` - Code string - ExpiresAt int64 - PersonID string -} - -func (DB_TemporaryCode) TableName() string { - return "ExchangeCodes" -} - type DB_DiscordPerson struct { ID string `gorm:"primary_key"` PersonID string @@ -167,11 +156,11 @@ type DB_SeasonStat struct { ID string `gorm:"primary_key"` PersonID string Build string - Level int XP int - Tier int - Stars int + Level int LevelClaimed int + Stars int + Tier int TierClaimed int }