mirror of
https://github.com/samsonjs/retrogit.git
synced 2026-04-27 15:07:43 +00:00
Account deletion button.
This commit is contained in:
parent
395fe41c7c
commit
7a24dfef8f
5 changed files with 52 additions and 0 deletions
|
|
@ -98,6 +98,12 @@ func (account *Account) Put(c appengine.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (account *Account) Delete(c appengine.Context) error {
|
||||||
|
key := datastore.NewKey(c, "Account", "", int64(account.GitHubUserId), nil)
|
||||||
|
err := datastore.Delete(c, key)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (account *Account) GetDigestEmailAddress(githubClient *github.Client) (string, error) {
|
func (account *Account) GetDigestEmailAddress(githubClient *github.Client) (string, error) {
|
||||||
if len(account.DigestEmailAddress) > 0 {
|
if len(account.DigestEmailAddress) > 0 {
|
||||||
return account.DigestEmailAddress, nil
|
return account.DigestEmailAddress, nil
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ func init() {
|
||||||
|
|
||||||
router.HandleFunc("/account/settings", settingsHandler).Name("settings").Methods("GET")
|
router.HandleFunc("/account/settings", settingsHandler).Name("settings").Methods("GET")
|
||||||
router.HandleFunc("/account/settings", saveSettingsHandler).Name("save-settings").Methods("POST")
|
router.HandleFunc("/account/settings", saveSettingsHandler).Name("save-settings").Methods("POST")
|
||||||
|
router.HandleFunc("/account/delete", deleteAccountHandler).Name("delete-account").Methods("POST")
|
||||||
|
|
||||||
router.HandleFunc("/admin/digest", digestAdminHandler)
|
router.HandleFunc("/admin/digest", digestAdminHandler)
|
||||||
http.Handle("/", router)
|
http.Handle("/", router)
|
||||||
|
|
@ -512,6 +513,24 @@ func saveSettingsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Redirect(w, r, settingsUrl.String(), http.StatusFound)
|
http.Redirect(w, r, settingsUrl.String(), http.StatusFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func deleteAccountHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
session, _ := sessionStore.Get(r, sessionConfig.CookieName)
|
||||||
|
userId := session.Values[sessionConfig.UserIdKey].(int)
|
||||||
|
c := appengine.NewContext(r)
|
||||||
|
account, err := getAccount(c, userId)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
account.Delete(c)
|
||||||
|
session.Options.MaxAge = -1
|
||||||
|
session.Save(r, w)
|
||||||
|
|
||||||
|
indexUrl, _ := router.Get("index").URL()
|
||||||
|
http.Redirect(w, r, indexUrl.String(), http.StatusFound)
|
||||||
|
}
|
||||||
|
|
||||||
func digestAdminHandler(w http.ResponseWriter, r *http.Request) {
|
func digestAdminHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
userId, err := strconv.Atoi(r.FormValue("user_id"))
|
userId, err := strconv.Atoi(r.FormValue("user_id"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -67,3 +67,21 @@ a {
|
||||||
color: #999;
|
color: #999;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#delete-account-form {
|
||||||
|
border-top: solid 1px #ccc;
|
||||||
|
margin-top: 1em;
|
||||||
|
padding-top: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="submit"].destructive {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
display: inline;
|
||||||
|
background: transparent;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
font-family: Helvetica, Arial, sans-serif;
|
||||||
|
font-size: 10pt;
|
||||||
|
text-decoration: underline;
|
||||||
|
color: #900;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,3 +21,7 @@ function updateReposContainer() {
|
||||||
reposContainerNode.style.display = "none";
|
reposContainerNode.style.display = "none";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function confirmDeleteAccount() {
|
||||||
|
return confirm("Are you sure you want to delete your account?");
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,11 @@
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<form id="delete-account-form" method="POST" action="{{routeUrl "delete-account"}}" onsubmit="return confirmDeleteAccount()">
|
||||||
|
If you'd like all data that's stored about your GitHub account removed, you can
|
||||||
|
<input type="submit" value="Delete Your Account" class="destructive">.
|
||||||
|
</form>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
updateWeeklyDayContainer();
|
updateWeeklyDayContainer();
|
||||||
updateReposContainer();
|
updateReposContainer();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue