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.

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