blob: 1665acb0ec2b6a84e806b472fc6ca4ad0f2fd6ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
package main
import (
"github.com/gorilla/sessions"
"github.com/silvasur/mailremind/model"
"log"
"net/http"
)
type reallydeleteTpldata struct {
OK bool
}
func deleteask(user model.User, sess *sessions.Session, req *http.Request) (interface{}, model.User) {
return &reallydeleteTpldata{user != nil}, user
}
func deleteacc(user model.User, sess *sessions.Session, req *http.Request) (interface{}, model.User) {
outdata := &msgTpldata{Title: "Delete Account"}
if user == nil {
outdata.Class = "error"
outdata.Msg = "You need to be logged in to do that"
return outdata, user
}
if err := user.Delete(); err != nil {
log.Printf("Error while deleting account: %s", err)
outdata.Class = "error"
outdata.Msg = "An error occurred during deletion."
return outdata, user
}
delete(sess.Values, "uid")
outdata.Class = "success"
outdata.Msg = "Account deleted."
return outdata, user
}
|