The backend for the AiteStory website
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
633 B

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. package viewmodel
  2. import (
  3. "fmt"
  4. "log"
  5. "git.aiterp.net/AiteRP/aitestory/server"
  6. "git.aiterp.net/gisle/wrouter/auth"
  7. )
  8. // Base is the basic information used to render the page
  9. type Base struct {
  10. User struct {
  11. Name string
  12. Role string
  13. LoggedIn bool
  14. }
  15. ViewTitle string
  16. }
  17. // InitBase initializes the base of the viewmodel
  18. func (base *Base) setupBase(user *auth.User, viewTitle string) {
  19. if user != nil {
  20. log.Printf("%+v", user)
  21. base.User.Name = user.ID
  22. base.User.Role = user.Data["role"]
  23. base.User.LoggedIn = true
  24. }
  25. base.ViewTitle = fmt.Sprintf("%s - %s", viewTitle, server.Main.Config.View.Title)
  26. }