This commit is contained in:
konrad 2018-08-30 19:14:16 +02:00 committed by kolaente
parent 478c98fb8d
commit 76f3357a0c
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
3 changed files with 22 additions and 22 deletions

View File

@ -22,7 +22,7 @@ type List struct {
func (l *List) AfterLoad() {
// Get the owner
l.Owner, _= GetUserByID(l.OwnerID)
l.Owner, _ = GetUserByID(l.OwnerID)
// Get the list tasks
l.Tasks, _ = GetTasksByListID(l.ID)

View File

@ -84,27 +84,27 @@ func UpdateUser(user User) (updatedUser User, err error) {
return User{}, err
}
// Check if we have at least a username
if user.Username == "" {
//return User{}, ErrNoUsername{user.ID}
user.Username = theUser.Username // Dont change the username if we dont have one
}
// Check if we have at least a username
if user.Username == "" {
//return User{}, ErrNoUsername{user.ID}
user.Username = theUser.Username // Dont change the username if we dont have one
}
user.Password = theUser.Password // set the password to the one in the database to not accedently resetting it
user.Password = theUser.Password // set the password to the one in the database to not accedently resetting it
// Update it
_, err = x.Id(user.ID).Update(user)
if err != nil {
return User{}, err
}
// Update it
_, err = x.Id(user.ID).Update(user)
if err != nil {
return User{}, err
}
// Get the newly updated user
updatedUser, err = GetUserByID(user.ID)
if err != nil {
return User{}, err
}
// Get the newly updated user
updatedUser, err = GetUserByID(user.ID)
if err != nil {
return User{}, err
}
return updatedUser, err
return updatedUser, err
}
// UpdateUserPassword updates the password of a user

View File

@ -61,10 +61,10 @@ func userAddOrUpdate(c echo.Context) error {
var exists bool
_, err := models.GetUserByID(datUser.ID)
if err != nil {
if models.IsErrUserDoesNotExist(err) {
exists = true
} else {
return c.JSON(http.StatusInternalServerError, models.Message{"Could not check if the user exists."})
if models.IsErrUserDoesNotExist(err) {
exists = true
} else {
return c.JSON(http.StatusInternalServerError, models.Message{"Could not check if the user exists."})
}
}