summaryrefslogtreecommitdiff
path: root/model/mysql/users.go
diff options
context:
space:
mode:
Diffstat (limited to 'model/mysql/users.go')
-rw-r--r--model/mysql/users.go26
1 files changed, 18 insertions, 8 deletions
diff --git a/model/mysql/users.go b/model/mysql/users.go
index 017d34f..f4e3c1c 100644
--- a/model/mysql/users.go
+++ b/model/mysql/users.go
@@ -62,16 +62,17 @@ func (con *MySQLDBCon) UserByMail(email string) (model.User, error) {
return userFromSQL(con, row)
}
-func (u *User) ID() model.DBID { return u.id }
-func (u *User) Email() string { return u.email }
-func (u *User) PWHash() []byte { return []byte(u.passwd) }
-func (u *User) Active() bool { return u.active }
-func (u *User) ActivationCode() string { return u.acCode }
+func (u *User) ID() model.DBID { return u.id }
+func (u *User) Email() string { return u.email }
+func (u *User) PWHash() []byte { return []byte(u.passwd) }
+func (u *User) Active() bool { return u.active }
+func (u *User) ActivationCode() string { return u.acCode }
+func (u *User) Location() *time.Location { return u.location }
func (u *User) SetPWHash(_pwhash []byte) error {
pwhash := string(_pwhash)
- if _, err := u.con.stmt[qSetPWHash].Query(pwhash, uint64(u.id)); err != nil {
+ if _, err := u.con.stmt[qSetPWHash].Exec(pwhash, uint64(u.id)); err != nil {
return err
}
@@ -80,7 +81,7 @@ func (u *User) SetPWHash(_pwhash []byte) error {
}
func (u *User) SetActive(b bool) error {
- if _, err := u.con.stmt[qSetActive].Query(b2i(b), uint64(u.id)); err != nil {
+ if _, err := u.con.stmt[qSetActive].Exec(b2i(b), uint64(u.id)); err != nil {
return err
}
@@ -89,7 +90,7 @@ func (u *User) SetActive(b bool) error {
}
func (u *User) SetActivationCode(c string) error {
- if _, err := u.con.stmt[qSetAcCode].Query(c, uint64(u.id)); err != nil {
+ if _, err := u.con.stmt[qSetAcCode].Exec(c, uint64(u.id)); err != nil {
return err
}
@@ -97,6 +98,15 @@ func (u *User) SetActivationCode(c string) error {
return nil
}
+func (u *User) SetLocation(loc *time.Location) error {
+ if _, err := u.con.stmt[qSetLocation].Exec(loc.String(), uint64(u.id)); err != nil {
+ return err
+ }
+
+ u.location = loc
+ return nil
+}
+
func (u *User) Delete() error {
tx, err := u.con.con.Begin()
if err != nil {