mirror of
https://github.com/samsonjs/retrogit.git
synced 2026-04-27 15:07:43 +00:00
Add sign out link.
This commit is contained in:
parent
97683cb538
commit
ceafd4035a
3 changed files with 17 additions and 9 deletions
1
TODO
1
TODO
|
|
@ -1,5 +1,4 @@
|
||||||
TODO
|
TODO
|
||||||
- Sign out link
|
|
||||||
- Persist OAuth token in the datastore and use session cookies
|
- Persist OAuth token in the datastore and use session cookies
|
||||||
- Flash message and sign out when OAuth token has expired/is invalid
|
- Flash message and sign out when OAuth token has expired/is invalid
|
||||||
- Handle pagination for user repository list
|
- Handle pagination for user repository list
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ func signInHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
func signOutHandler(w http.ResponseWriter, r *http.Request) {
|
func signOutHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
session, _ := sessionStore.Get(r, sessionConfig.CookieName)
|
session, _ := sessionStore.Get(r, sessionConfig.CookieName)
|
||||||
session.Options.MaxAge = 0
|
session.Options.MaxAge = -1
|
||||||
session.Save(r, w)
|
session.Save(r, w)
|
||||||
indexUrl, _ := router.Get("index").URL()
|
indexUrl, _ := router.Get("index").URL()
|
||||||
http.Redirect(w, r, indexUrl.String(), http.StatusFound)
|
http.Redirect(w, r, indexUrl.String(), http.StatusFound)
|
||||||
|
|
@ -168,10 +168,10 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
tokenEncoded, ok := session.Values[sessionConfig.TokenKey].(string)
|
tokenEncoded, ok := session.Values[sessionConfig.TokenKey].(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
signInUrl, _ := router.Get("sign-in").URL()
|
signInUrl, _ := router.Get("sign-in").URL()
|
||||||
var signedOutParams = map[string]string{
|
var data = map[string]string{
|
||||||
"SignInUrl": signInUrl.String(),
|
"SignInUrl": signInUrl.String(),
|
||||||
}
|
}
|
||||||
if err := indexSignedOutTemplate.Execute(w, signedOutParams); err != nil {
|
if err := indexSignedOutTemplate.Execute(w, data); err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
@ -239,8 +239,12 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
signOutUrl, _ := router.Get("sign-out").URL()
|
||||||
if err := indexTemplate.Execute(w, digest); err != nil {
|
var data = map[string]interface{}{
|
||||||
|
"SignOutUrl": signOutUrl.String(),
|
||||||
|
"Digest": digest,
|
||||||
|
}
|
||||||
|
if err := indexTemplate.Execute(w, data); err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -262,7 +266,6 @@ func githubOAuthCallbackHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
session, _ := sessionStore.Get(r, sessionConfig.CookieName)
|
session, _ := sessionStore.Get(r, sessionConfig.CookieName)
|
||||||
session.Values[sessionConfig.TokenKey] = tokenEncoded
|
session.Values[sessionConfig.TokenKey] = tokenEncoded
|
||||||
session.Save(r, w)
|
session.Save(r, w)
|
||||||
log.Printf("session.Values: %s", session.Values)
|
|
||||||
indexUrl, _ := router.Get("index").URL()
|
indexUrl, _ := router.Get("index").URL()
|
||||||
http.Redirect(w, r, indexUrl.String(), http.StatusFound)
|
http.Redirect(w, r, indexUrl.String(), http.StatusFound)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,15 @@
|
||||||
<body>
|
<body>
|
||||||
<h1>GitHop!</h1>
|
<h1>GitHop!</h1>
|
||||||
|
|
||||||
{{.User.Login}}'s digest:
|
<p>
|
||||||
|
<a href="{{.SignOutUrl}}">
|
||||||
|
Sign Out
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{{.Digest.User.Login}}'s digest:
|
||||||
<ul>
|
<ul>
|
||||||
{{range $index, $repoDigest := .RepoDigests}}
|
{{range $index, $repoDigest := .Digest.RepoDigests}}
|
||||||
<li>
|
<li>
|
||||||
<a href="https://github.com/{{.Repo.FullName}}">
|
<a href="https://github.com/{{.Repo.FullName}}">
|
||||||
{{.Repo.FullName}}
|
{{.Repo.FullName}}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue