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

9
.gitignore vendored
View File

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

View File

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

View File

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

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
}