Fix bug not letting the first user have a session after user creation
This commit is contained in:
parent
88776337e4
commit
0e825a55e5
@ -252,7 +252,7 @@ func UpdateSelf(c *b.Config, db *b.DB, s map[string]*Session) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddFirstUser(c *b.Config, db *b.DB, s map[string]*Session) http.HandlerFunc {
|
func AddFirstUser(c *b.Config, db *b.DB, s map[string]*Session, sessionExpiryChan chan string) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var err error
|
var err error
|
||||||
user := &b.User{
|
user := &b.User{
|
||||||
@ -305,8 +305,12 @@ func AddFirstUser(c *b.Config, db *b.DB, s map[string]*Session) http.HandlerFunc
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
session := newSession(w, c, sessionExpiryChan, user)
|
||||||
|
s[session.cookie.Value] = session
|
||||||
|
http.SetCookie(w, session.cookie)
|
||||||
|
|
||||||
data := new(struct{ Role int })
|
data := new(struct{ Role int })
|
||||||
data.Role = 0
|
data.Role = user.Role
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", data); err != nil {
|
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", data); err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user