remove not needed db tables

This commit is contained in:
Eccentric 2023-12-26 03:18:12 +00:00
parent 5c9bbb2f89
commit 7d51c8dd07
5 changed files with 11 additions and 37 deletions

View File

@ -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")
}

View File

@ -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")

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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
}