Add current user

This commit is contained in:
Henrique Dias 2016-08-21 19:14:52 +01:00
parent 256bdd2f95
commit 9b39fe78ba
2 changed files with 23 additions and 0 deletions

View File

@ -170,6 +170,17 @@ func (i *Info) serveSingleFile(w http.ResponseWriter, r *http.Request, c *config
},
}
// Set the current User
user, _, ok := r.BasicAuth()
if !ok {
page.Info.User = c.UserConfig
}
if _, ok := c.Users[user]; ok {
page.Info.User = c.Users[user]
}
if CanBeEdited(i.Name) {
editor, err := i.GetEditor()
@ -250,6 +261,17 @@ func (i *Info) serveListing(w http.ResponseWriter, r *http.Request, c *config.Co
},
}
// Set the current User
user, _, ok := r.BasicAuth()
if !ok {
page.Info.User = c.UserConfig
}
if _, ok := c.Users[user]; ok {
page.Info.User = c.Users[user]
}
if r.Header.Get("Minimal") == "true" {
page.Minimal = true
}

View File

@ -25,6 +25,7 @@ type Info struct {
Path string
IsDir bool
Config *config.Config
User *config.UserConfig
Data interface{}
}