tangled
alpha
login
or
join now
tjh.dev
/
core
forked from
tangled.org/core
0
fork
atom
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
return to / if already logged in at /login
anirudh.fi
1 year ago
316e40fc
1a3a88d8
verified
This commit was signed with the committer's
known signature
.
anirudh.fi
SSH Key Fingerprint:
SHA256:FQUiBXeyBQT4WKOm7EKh6hLkHjBh9MdfkV3my0dueGE=
+14
-4
3 changed files
expand all
collapse all
unified
split
legit
routes
auth.go
handler.go
routes.go
+7
legit/routes/auth.go
···
20
20
auth, ok := session.Values["authenticated"].(bool)
21
21
22
22
if !ok || !auth {
23
23
+
log.Printf("not logged in, redirecting")
23
24
http.Redirect(w, r, "/login", http.StatusTemporaryRedirect)
24
25
return
25
26
}
···
58
59
}
59
60
60
61
log.Println("successfully refreshed token")
62
62
+
}
63
63
+
64
64
+
if r.URL.Path == "/login" {
65
65
+
log.Println("already logged in")
66
66
+
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
67
67
+
return
61
68
}
62
69
63
70
next.ServeHTTP(w, r)
+5
-2
legit/routes/handler.go
···
60
60
auth: auth,
61
61
}
62
62
63
63
-
r.Get("/login", h.Login)
64
64
-
r.Post("/login", h.Login)
63
63
+
r.Group(func(r chi.Router) {
64
64
+
r.Use(h.AuthMiddleware)
65
65
+
r.Get("/login", h.Login)
66
66
+
r.Post("/login", h.Login)
67
67
+
})
65
68
r.Get("/static/{file}", h.ServeStatic)
66
69
67
70
r.Route("/repo", func(r chi.Router) {
+2
-2
legit/routes/routes.go
···
463
463
}
464
464
465
465
log.Printf("successfully saved session for %s (%s)", atSession.Handle, atSession.Did)
466
466
-
w.Header().Set("HX-Redirect", "/")
467
467
-
w.WriteHeader(http.StatusOK)
466
466
+
http.Redirect(w, r, "/", http.StatusPermanentRedirect)
467
467
+
return
468
468
}
469
469
}
470
470