summaryrefslogtreecommitdiff
path: root/activate.go
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2013-09-05 21:50:44 +0200
committerKevin Chabowski <kevin@kch42.de>2013-09-05 21:50:44 +0200
commit6f4d4569a5227e1962f5f7a81e1a63b6046cfb6c (patch)
tree0e0a49b15f67de1816c756de04eb8f0f4a9a2288 /activate.go
parent0829fda06733674abdc340ec17c0fbfb4fd778ae (diff)
downloadmailremind-6f4d4569a5227e1962f5f7a81e1a63b6046cfb6c.tar.gz
mailremind-6f4d4569a5227e1962f5f7a81e1a63b6046cfb6c.tar.bz2
mailremind-6f4d4569a5227e1962f5f7a81e1a63b6046cfb6c.zip
Menu options change drectly on Login/Logout
Diffstat (limited to 'activate.go')
-rw-r--r--activate.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/activate.go b/activate.go
index 56ef897..59e7eed 100644
--- a/activate.go
+++ b/activate.go
@@ -7,7 +7,7 @@ import (
"net/http"
)
-func activate(user model.User, sess *sessions.Session, req *http.Request) interface{} {
+func activate(user model.User, sess *sessions.Session, req *http.Request) (interface{}, model.User) {
outdata := &msgTpldata{Title: "Activate Account", Class: "error"}
req.ParseForm()
@@ -17,44 +17,44 @@ func activate(user model.User, sess *sessions.Session, req *http.Request) interf
if (_userid == "") || (code == "") {
outdata.Msg = "User or code invalid. Check, if the activation link was correctly copied from the mail."
- return outdata
+ return outdata, user
}
userid, err := db.ParseDBID(_userid)
if err != nil {
outdata.Msg = "User or code invalid. Check, if the activation link was correctly copied from the mail."
- return outdata
+ return outdata, user
}
switch user, err = dbcon.UserByID(userid); err {
case nil:
case model.NotFound:
outdata.Msg = "User not found."
- return outdata
+ return outdata, user
default:
log.Printf("Error while getting user by ID <%s>: %s", userid, err)
outdata.Msg = "An error occurred while loading user data. Send a message to the support, if this happens again."
- return outdata
+ return outdata, user
}
if user.ActivationCode() != code {
outdata.Msg = "Wrong activation code."
- return outdata
+ return outdata, user
}
if err := user.SetActivationCode(""); err != nil {
log.Printf("Error while resetting activation code: %s", err)
outdata.Msg = "An error occurred while activating the user. Send a message to the support, if this happens again."
- return outdata
+ return outdata, user
}
if err := user.SetActive(true); err != nil {
log.Printf("Error while resetting activation code: %s", err)
outdata.Msg = "An error occurred while activating the user. Send a message to the support, if this happens again."
- return outdata
+ return outdata, user
}
outdata.Class = "success"
outdata.Msg = "Account activated!"
- return outdata
+ return outdata, user
}