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.

38 lines
829 B

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