Refactor
This commit is contained in:
@ -1,17 +0,0 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// IsProduction returns true if the hostname contains "arn".
|
||||
func IsProduction() bool {
|
||||
host, _ := os.Hostname()
|
||||
return strings.Contains(host, "arn")
|
||||
}
|
||||
|
||||
// IsDevelopment returns true if the hostname does not contain "arn".
|
||||
func IsDevelopment() bool {
|
||||
return !IsProduction()
|
||||
}
|
@ -5,23 +5,7 @@ import (
|
||||
"github.com/animenotifier/arn"
|
||||
)
|
||||
|
||||
// GetUser ...
|
||||
// GetUser returns the logged in user for the given context.
|
||||
func GetUser(ctx *aero.Context) *arn.User {
|
||||
if !ctx.HasSession() {
|
||||
return nil
|
||||
}
|
||||
|
||||
userID := ctx.Session().GetString("userId")
|
||||
|
||||
if userID == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
user, err := arn.GetUser(userID)
|
||||
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return user
|
||||
return arn.GetUserFromContext(ctx)
|
||||
}
|
||||
|
Reference in New Issue
Block a user