(db *gorm.DB, next http.HandlerFunc)
| 159 | } |
| 160 | |
| 161 | func GuestOnly(db *gorm.DB, next http.HandlerFunc) http.HandlerFunc { |
| 162 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 163 | _, ok, err := AuthWithSession(db, r) |
| 164 | if err != nil { |
| 165 | // log the error and continue |
| 166 | log.ErrorWrap(err, "authenticating with session") |
| 167 | } |
| 168 | |
| 169 | if ok { |
| 170 | http.Redirect(w, r, "/", http.StatusFound) |
| 171 | } else { |
| 172 | next.ServeHTTP(w, r) |
| 173 | } |
| 174 | }) |
| 175 | } |