From a007e53b037a08ce34efd0b936dfa03127c2b7d1 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Fri, 30 Aug 2013 23:46:32 +0200 Subject: Added {,Set}Location to model --- model/mysql/users.go | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'model/mysql/users.go') 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 { -- cgit v1.2.3-54-g00ecf