Changeset 324 in code for trunk/user.go


Ignore:
Timestamp:
Jun 8, 2020, 9:59:03 AM (5 years ago)
Author:
contact
Message:

Introduce User.Created

For Network and Channel, the database only needed to define one Store
operation to create/update a record. However since User is missing an ID
we couldn't have a single StoreUser function like other types. We had
CreateUser and UpdatePassword. As new User fields get added (e.g. the
upcoming Admin flag) this isn't sustainable.

We could have CreateUser and UpdateUser, but this wouldn't be consistent
with other types. Instead, introduce User.Created which indicates
whether the record is already stored in the DB. This can be used in a
new StoreUser function to decide whether we need to UPDATE or INSERT
without relying on SQL constraints and INSERT OR UPDATE.

The ListUsers and GetUser functions set User.Created to true.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/user.go

    r313 r324  
    548548func (u *user) updatePassword(hashed string) error {
    549549        u.User.Password = hashed
    550         return u.srv.db.UpdatePassword(&u.User)
    551 }
     550        return u.srv.db.StoreUser(&u.User)
     551}
Note: See TracChangeset for help on using the changeset viewer.