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.

33 lines
711 B

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. ViewTitle string
  17. }
  18. // InitBase initializes the base of the viewmodel
  19. func (base *Base) setupBase(user *auth.User, viewTitle string) {
  20. if user != nil {
  21. base.User.ID = user.FullID()
  22. base.User.Name = user.ID
  23. base.User.Role = user.Data["role"]
  24. base.User.LoggedIn = true
  25. base.User.SessionID = user.Session.ID
  26. }
  27. base.ViewTitle = fmt.Sprintf("%s - %s", viewTitle, server.Main.Config.View.Title)
  28. }