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.

34 lines
682 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. ID string
  12. Name string
  13. Role string
  14. LoggedIn bool
  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. log.Printf("%+v", user)
  22. base.User.ID = user.FullID()
  23. base.User.Name = user.ID
  24. base.User.Role = user.Data["role"]
  25. base.User.LoggedIn = true
  26. }
  27. base.ViewTitle = fmt.Sprintf("%s - %s", viewTitle, server.Main.Config.View.Title)
  28. }