2019-09-28 17:04:51 -07:00
|
|
|
package auth
|
|
|
|
|
|
2020-07-08 18:59:37 -07:00
|
|
|
// import "net/http"
|
2019-09-28 17:04:51 -07:00
|
|
|
|
2020-07-08 18:59:37 -07:00
|
|
|
// func IsAuthenticated(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
|
2019-09-28 17:04:51 -07:00
|
|
|
|
2020-07-08 18:59:37 -07:00
|
|
|
// session, err := Store.Get(r, SessionName)
|
|
|
|
|
// if err != nil {
|
|
|
|
|
// http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
|
|
|
// return
|
|
|
|
|
// }
|
2019-09-28 17:04:51 -07:00
|
|
|
|
2020-07-08 18:59:37 -07:00
|
|
|
// if _, ok := session.Values["profile"]; !ok {
|
|
|
|
|
// //TODO allow customization of redirect
|
|
|
|
|
// http.Redirect(w, r, "/", http.StatusSeeOther)
|
|
|
|
|
// } else {
|
|
|
|
|
// next(w, r)
|
|
|
|
|
// }
|
|
|
|
|
// }
|