fix constructors, skip password compare as it's a complex type
This commit is contained in:
parent
4d62ca3290
commit
bc1f3aeb4c
@ -26,7 +26,7 @@ func (*Channel) Edit(r *channelEditRequest) (interface{}, error) {
|
||||
// @todo: permission check if user can add channel
|
||||
// @todo: make sure archived & deleted entries can not be edited
|
||||
|
||||
c := Channel{}.new().SetID(r.id).SetName(r.name).SetTopic(r.topic)
|
||||
c := Channel{}.New().SetID(r.id).SetName(r.name).SetTopic(r.topic)
|
||||
if c.GetID() > 0 {
|
||||
if is("topic", c.changed...) {
|
||||
fmt.Println("Topic for channel was changed:", c.GetTopic())
|
||||
@ -63,7 +63,7 @@ func (*Channel) Read(r *channelReadRequest) (interface{}, error) {
|
||||
|
||||
// @todo: permission check if user can read channel
|
||||
|
||||
c := Channel{}.new()
|
||||
c := Channel{}.New()
|
||||
return c, db.Get(c, sqlChannelSelect+" AND id = ?", r.id)
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ type ChannelHandlers struct {
|
||||
|
||||
func (ChannelHandlers) new() *ChannelHandlers {
|
||||
return &ChannelHandlers{
|
||||
Channel{}.new(),
|
||||
Channel{}.New(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -370,7 +370,7 @@
|
||||
"fields": [
|
||||
{ "type": "uint64", "name": "ID" },
|
||||
{ "type": "string", "name": "Username" },
|
||||
{ "type": "[]byte", "name": "Password", "tag": "json:\"-\"" },
|
||||
{ "type": "[]byte", "name": "Password", "tag": "json:\"-\"", "complex": true },
|
||||
{ "type": "*time.Time", "name": "SuspendedAt", "tag": "json:\",omitempty\"", "complex": true },
|
||||
{ "type": "*time.Time", "name": "DeletedAt", "tag": "json:\",omitempty\"", "complex": true }
|
||||
]
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"complex": true,
|
||||
"name": "Password",
|
||||
"tag": "json:\"-\"",
|
||||
"type": "[]byte"
|
||||
|
||||
@ -11,7 +11,7 @@ type MessageHandlers struct {
|
||||
|
||||
func (MessageHandlers) new() *MessageHandlers {
|
||||
return &MessageHandlers{
|
||||
Message{}.new(),
|
||||
Message{}.New(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ func (*Organisation) Edit(r *organisationEditRequest) (interface{}, error) {
|
||||
// @todo: permission check if user can add/edit organisation
|
||||
// @todo: make sure archived & deleted entries can not be edited
|
||||
|
||||
o := Organisation{}.new().SetID(r.id).SetName(r.name)
|
||||
o := Organisation{}.New().SetID(r.id).SetName(r.name)
|
||||
if o.GetID() > 0 {
|
||||
return o, db.Replace("organisation", o)
|
||||
}
|
||||
@ -55,7 +55,7 @@ func (*Organisation) Read(r *organisationReadRequest) (interface{}, error) {
|
||||
|
||||
// @todo: permissions check
|
||||
|
||||
o := Organisation{}.new()
|
||||
o := Organisation{}.New()
|
||||
return o, db.Get(o, sqlOrganisationSelect+" AND id = ?", r.id)
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ type OrganisationHandlers struct {
|
||||
|
||||
func (OrganisationHandlers) new() *OrganisationHandlers {
|
||||
return &OrganisationHandlers{
|
||||
Organisation{}.new(),
|
||||
Organisation{}.New(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ func (*Team) Edit(r *teamEditRequest) (interface{}, error) {
|
||||
// @todo: permission check if user can add/edit the team
|
||||
// @todo: make sure archived & deleted entries can not be edited
|
||||
|
||||
t := Team{}.new()
|
||||
t := Team{}.New()
|
||||
t.SetID(r.id).SetName(r.name).SetMemberIDs(r.members)
|
||||
if t.GetID() > 0 {
|
||||
return t, db.Replace("team", t)
|
||||
@ -51,7 +51,7 @@ func (*Team) Read(r *teamReadRequest) (interface{}, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
t := Team{}.new()
|
||||
t := Team{}.New()
|
||||
return t, db.Get(t, sqlTeamSelect+" AND id = ?", r.id)
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ type TeamHandlers struct {
|
||||
|
||||
func (TeamHandlers) new() *TeamHandlers {
|
||||
return &TeamHandlers{
|
||||
Team{}.new(),
|
||||
Team{}.New(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ type {name}Handlers struct {
|
||||
|
||||
func ({name}Handlers) new() *{name}Handlers {
|
||||
return &{name}Handlers{
|
||||
{name}{}.new(),
|
||||
{name}{}.New(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ func (*User) Read(r *teamReadRequest) (interface{}, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
t := User{}.new()
|
||||
t := User{}.New()
|
||||
return t, db.Get(t, sqlUserSelect+" AND id = ?", r.id)
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ func (*User) Login(r *userLoginRequest) (interface{}, error) {
|
||||
}
|
||||
|
||||
u := &User{}
|
||||
if err != db.Get(u, sqlUserSelect+" AND username = ?", r.username) {
|
||||
if err = db.Get(u, sqlUserSelect+" AND username = ?", r.username); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ type UserHandlers struct {
|
||||
|
||||
func (UserHandlers) new() *UserHandlers {
|
||||
return &UserHandlers{
|
||||
User{}.new(),
|
||||
User{}.New(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -50,10 +50,7 @@ func (u *User) GetPassword() []byte {
|
||||
}
|
||||
|
||||
func (u *User) SetPassword(value []byte) *User {
|
||||
if u.Password != value {
|
||||
u.changed = append(u.changed, "Password")
|
||||
u.Password = value
|
||||
}
|
||||
u.Password = value
|
||||
return u
|
||||
}
|
||||
func (u *User) GetSuspendedAt() *time.Time {
|
||||
|
||||
@ -11,7 +11,7 @@ type WebsocketHandlers struct {
|
||||
|
||||
func (WebsocketHandlers) new() *WebsocketHandlers {
|
||||
return &WebsocketHandlers{
|
||||
Websocket{}.new(),
|
||||
Websocket{}.New(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user