Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
03f26006
authored
Apr 24, 2024
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update user
parent
bbac1a53
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
+10
-4
controller/user.go
+2
-2
model/user.go
+8
-2
No files found.
controller/user.go
View file @
03f26006
...
@@ -453,7 +453,7 @@ func UpdateUser(c *gin.Context) {
...
@@ -453,7 +453,7 @@ func UpdateUser(c *gin.Context) {
updatedUser
.
Password
=
""
// rollback to what it should be
updatedUser
.
Password
=
""
// rollback to what it should be
}
}
updatePassword
:=
updatedUser
.
Password
!=
""
updatePassword
:=
updatedUser
.
Password
!=
""
if
err
:=
updatedUser
.
Update
(
updatePassword
);
err
!=
nil
{
if
err
:=
updatedUser
.
Edit
(
updatePassword
);
err
!=
nil
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
false
,
"success"
:
false
,
"message"
:
err
.
Error
(),
"message"
:
err
.
Error
(),
...
@@ -726,7 +726,7 @@ func ManageUser(c *gin.Context) {
...
@@ -726,7 +726,7 @@ func ManageUser(c *gin.Context) {
user
.
Role
=
common
.
RoleCommonUser
user
.
Role
=
common
.
RoleCommonUser
}
}
if
err
:=
user
.
Update
All
(
false
);
err
!=
nil
{
if
err
:=
user
.
Update
(
false
);
err
!=
nil
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
false
,
"success"
:
false
,
"message"
:
err
.
Error
(),
"message"
:
err
.
Error
(),
...
...
model/user.go
View file @
03f26006
...
@@ -244,7 +244,7 @@ func (user *User) Update(updatePassword bool) error {
...
@@ -244,7 +244,7 @@ func (user *User) Update(updatePassword bool) error {
return
err
return
err
}
}
func
(
user
*
User
)
UpdateAll
(
updatePassword
bool
)
error
{
func
(
user
*
User
)
Edit
(
updatePassword
bool
)
error
{
var
err
error
var
err
error
if
updatePassword
{
if
updatePassword
{
user
.
Password
,
err
=
common
.
Password2Hash
(
user
.
Password
)
user
.
Password
,
err
=
common
.
Password2Hash
(
user
.
Password
)
...
@@ -254,7 +254,13 @@ func (user *User) UpdateAll(updatePassword bool) error {
...
@@ -254,7 +254,13 @@ func (user *User) UpdateAll(updatePassword bool) error {
}
}
newUser
:=
*
user
newUser
:=
*
user
DB
.
First
(
&
user
,
user
.
Id
)
DB
.
First
(
&
user
,
user
.
Id
)
err
=
DB
.
Model
(
user
)
.
Select
(
"*"
)
.
Updates
(
newUser
)
.
Error
err
=
DB
.
Model
(
user
)
.
Updates
(
map
[
string
]
interface
{}{
"username"
:
newUser
.
Username
,
"password"
:
newUser
.
Password
,
"display_name"
:
newUser
.
DisplayName
,
"group"
:
newUser
.
Group
,
"quota"
:
newUser
.
Quota
,
})
.
Error
if
err
==
nil
{
if
err
==
nil
{
if
common
.
RedisEnabled
{
if
common
.
RedisEnabled
{
_
=
common
.
RedisSet
(
fmt
.
Sprintf
(
"user_group:%d"
,
user
.
Id
),
user
.
Group
,
time
.
Duration
(
UserId2GroupCacheSeconds
)
*
time
.
Second
)
_
=
common
.
RedisSet
(
fmt
.
Sprintf
(
"user_group:%d"
,
user
.
Id
),
user
.
Group
,
time
.
Duration
(
UserId2GroupCacheSeconds
)
*
time
.
Second
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment