diff options
| author | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2024-07-09 11:31:08 +0530 | 
|---|---|---|
| committer | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2024-07-09 11:31:08 +0530 | 
| commit | c3821df233523ab715fdf06d54c142394411c968 (patch) | |
| tree | 4f19352740fc5e38b5a8bd98244bafa30e037b1c /user/service.go | |
| parent | d0a44ff5cfad5d063929426e2420f6f0d55b1dbe (diff) | |
added logo/signature upload routes
Diffstat (limited to 'user/service.go')
| -rw-r--r-- | user/service.go | 21 | 
1 files changed, 20 insertions, 1 deletions
diff --git a/user/service.go b/user/service.go index 4544cb4..222df4a 100644 --- a/user/service.go +++ b/user/service.go @@ -1,5 +1,5 @@  /* openbills - Server for web based Libre Billing Software - * Copyright (C) 2023  Vidhu Kant Sharma <vidhukant@vidhukant.com> + * Copyright (C) 2023-2024  Vidhu Kant Sharma <vidhukant@vidhukant.com>   *   * This program is free software: you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by @@ -75,3 +75,22 @@ func (u *User) del() error {  	return nil  } + +func (u *User) update(changes map[string]interface{}) error { +	res := db.Model(&u). +		Omit("email"). +		Omit("password"). +		Omit("username"). +		Updates(changes) + +	// TODO: handle potential errors +	if res.Error != nil { +		return res.Error +	} + +	if res.RowsAffected == 0 { +		return e.ErrNotFound +	} + +	return nil +}  |