diff --git a/.gitignore b/.gitignore index 09b2b8de..b9c14c7c 100644 --- a/.gitignore +++ b/.gitignore @@ -40,8 +40,11 @@ debug # binaries /notify.moe -# DB +# Database /db -# Cert -/security \ No newline at end of file +# Certificates +/security + +# Log files +/logs \ No newline at end of file diff --git a/contribute/.gitignore b/contribute/.gitignore deleted file mode 100644 index da84c421..00000000 --- a/contribute/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!install.sh diff --git a/pages/dashboard/dashboard.go b/pages/dashboard/dashboard.go index 8cea2b96..7cb8155c 100644 --- a/pages/dashboard/dashboard.go +++ b/pages/dashboard/dashboard.go @@ -1,10 +1,8 @@ package dashboard import ( - "net/http" - "github.com/aerogo/aero" - "github.com/animenotifier/arn" + "github.com/animenotifier/notify.moe/utils" ) const maxPosts = 5 @@ -24,15 +22,10 @@ func Get(ctx *aero.Context) string { // } // return ctx.HTML(components.Dashboard(posts)) - userID := ctx.Session().GetString("userId") - if userID != "" { - user, err := arn.GetUser(userID) - - if err != nil { - return ctx.Error(http.StatusInternalServerError, "Error fetching user data", err) - } + user := utils.GetUser(ctx) + if user != nil { return ctx.HTML("Welcome back, " + user.Nick + "!") } diff --git a/jobs/user-references/user-references.go b/patches/user-references/user-references.go similarity index 100% rename from jobs/user-references/user-references.go rename to patches/user-references/user-references.go diff --git a/contribute/install.sh b/temp/contribute/install.sh similarity index 100% rename from contribute/install.sh rename to temp/contribute/install.sh diff --git a/utils/user.go b/utils/user.go new file mode 100644 index 00000000..194c5498 --- /dev/null +++ b/utils/user.go @@ -0,0 +1,23 @@ +package utils + +import ( + "github.com/aerogo/aero" + "github.com/animenotifier/arn" +) + +// GetUser ... +func GetUser(ctx *aero.Context) *arn.User { + userID := ctx.Session().GetString("userId") + + if userID == "" { + return nil + } + + user, err := arn.GetUser(userID) + + if err != nil { + return nil + } + + return user +}