New directory structure

This commit is contained in:
Eduard Urbach 2017-06-07 23:37:13 +02:00
parent c222a814e4
commit fdbfb22ef5
6 changed files with 32 additions and 15 deletions

7
.gitignore vendored
View File

@ -40,8 +40,11 @@ debug
# binaries # binaries
/notify.moe /notify.moe
# DB # Database
/db /db
# Cert # Certificates
/security /security
# Log files
/logs

View File

@ -1,2 +0,0 @@
*
!install.sh

View File

@ -1,10 +1,8 @@
package dashboard package dashboard
import ( import (
"net/http"
"github.com/aerogo/aero" "github.com/aerogo/aero"
"github.com/animenotifier/arn" "github.com/animenotifier/notify.moe/utils"
) )
const maxPosts = 5 const maxPosts = 5
@ -24,15 +22,10 @@ func Get(ctx *aero.Context) string {
// } // }
// return ctx.HTML(components.Dashboard(posts)) // return ctx.HTML(components.Dashboard(posts))
userID := ctx.Session().GetString("userId")
if userID != "" { user := utils.GetUser(ctx)
user, err := arn.GetUser(userID)
if err != nil {
return ctx.Error(http.StatusInternalServerError, "Error fetching user data", err)
}
if user != nil {
return ctx.HTML("Welcome back, " + user.Nick + "!") return ctx.HTML("Welcome back, " + user.Nick + "!")
} }

23
utils/user.go Normal file
View File

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