Commit e750508d by Torkel Ödegaard

Fixes for update user and add token

parent 90925273
Subproject commit 1c5f902770c260f9bc63a0f07f1e9d22f60ce796 Subproject commit efe7279eadeffc4ba9f5a7b340e4ecdf4d208218
...@@ -13,7 +13,7 @@ func init() { ...@@ -13,7 +13,7 @@ func init() {
bus.AddHandler("sql", GetTokenByToken) bus.AddHandler("sql", GetTokenByToken)
bus.AddHandler("sql", UpdateToken) bus.AddHandler("sql", UpdateToken)
bus.AddHandler("sql", DeleteToken) bus.AddHandler("sql", DeleteToken)
bus.AddHandler("sql", DeleteToken) bus.AddHandler("sql", AddToken)
} }
func GetTokens(query *m.GetTokensQuery) error { func GetTokens(query *m.GetTokensQuery) error {
......
...@@ -12,6 +12,7 @@ import ( ...@@ -12,6 +12,7 @@ import (
func init() { func init() {
bus.AddHandler("sql", CreateUser) bus.AddHandler("sql", CreateUser)
bus.AddHandler("sql", UpdateUser)
bus.AddHandler("sql", GetUserByLogin) bus.AddHandler("sql", GetUserByLogin)
bus.AddHandler("sql", SetUsingAccount) bus.AddHandler("sql", SetUsingAccount)
bus.AddHandler("sql", GetUserInfo) bus.AddHandler("sql", GetUserInfo)
...@@ -92,6 +93,21 @@ func GetUserByLogin(query *m.GetUserByLoginQuery) error { ...@@ -92,6 +93,21 @@ func GetUserByLogin(query *m.GetUserByLoginQuery) error {
return nil return nil
} }
func UpdateUser(cmd *m.UpdateUserCommand) error {
return inTransaction(func(sess *xorm.Session) error {
user := m.User{
Name: cmd.Name,
Email: cmd.Email,
Login: cmd.Login,
Updated: time.Now(),
}
_, err := sess.Id(cmd.UserId).Update(&user)
return err
})
}
func SetUsingAccount(cmd *m.SetUsingAccountCommand) error { func SetUsingAccount(cmd *m.SetUsingAccountCommand) error {
return inTransaction(func(sess *xorm.Session) error { return inTransaction(func(sess *xorm.Session) error {
user := m.User{} user := m.User{}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment