2015-07-29 07:01:23 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-12-28 01:40:20 +00:00
|
|
|
"context"
|
2015-07-29 07:01:23 +00:00
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/flosch/pongo2"
|
|
|
|
"github.com/gorilla/sessions"
|
|
|
|
)
|
|
|
|
|
2017-12-28 01:40:20 +00:00
|
|
|
func overviewHandler(c context.Context, res http.ResponseWriter, r *http.Request, session *sessions.Session, ctx *pongo2.Context) (*string, error) {
|
|
|
|
user, _ := checkLogin(c, r, session)
|
2015-07-29 07:01:23 +00:00
|
|
|
|
2017-12-28 01:40:20 +00:00
|
|
|
if user == nil || !storage.IsPresent(c, user.UserFile) {
|
2015-07-29 07:01:23 +00:00
|
|
|
http.Redirect(res, r, "../../login", http.StatusFound)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
frontendAccounts := []string{}
|
|
|
|
idx := -1
|
|
|
|
for i, v := range session.Values["authorizedAccounts"].(authorizedAccounts) {
|
|
|
|
frontendAccounts = append(frontendAccounts, v.Name)
|
|
|
|
if v.Name == user.Name {
|
|
|
|
idx = i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
(*ctx)["authorized_accounts"] = frontendAccounts
|
|
|
|
(*ctx)["current_user_index"] = idx
|
|
|
|
|
2015-07-29 07:49:23 +00:00
|
|
|
return stringPointer("overview.html"), nil
|
2015-07-29 07:01:23 +00:00
|
|
|
}
|