Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
b511a7b6
Unverified
Commit
b511a7b6
authored
Nov 25, 2022
by
boojack
Committed by
GitHub
Nov 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: user patch with empty email (#578)
parent
88c3b1ad
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
7 deletions
+15
-7
user.go
server/user.go
+1
-1
UpdateAccountDialog.tsx
web/src/components/UpdateAccountDialog.tsx
+13
-5
UserBanner.tsx
web/src/components/UserBanner.tsx
+1
-1
No files found.
server/user.go
View file @
b511a7b6
...
...
@@ -199,7 +199,7 @@ func (s *Server) registerUserRoutes(g *echo.Group) {
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted patch user request"
)
.
SetInternal
(
err
)
}
if
userPatch
.
Email
!=
nil
&&
!
common
.
ValidateEmail
(
*
userPatch
.
Email
)
{
if
userPatch
.
Email
!=
nil
&&
*
userPatch
.
Email
!=
""
&&
!
common
.
ValidateEmail
(
*
userPatch
.
Email
)
{
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Invalid email format"
)
}
...
...
web/src/components/UpdateAccountDialog.tsx
View file @
b511a7b6
import
{
isEqual
}
from
"lodash"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
useTranslation
}
from
"react-i18next"
;
import
{
useAppSelector
}
from
"../store"
;
...
...
@@ -64,12 +65,19 @@ const UpdateAccountDialog: React.FC<Props> = ({ destroy }: Props) => {
try
{
const
user
=
userService
.
getState
().
user
as
User
;
await
userService
.
patchUser
(
{
const
userPatch
:
UserPatch
=
{
id
:
user
.
id
,
username
:
state
.
username
,
nickname
:
state
.
nickname
,
email
:
state
.
email
,
});
};
if
(
!
isEqual
(
user
.
nickname
,
state
.
nickname
))
{
userPatch
.
nickname
=
state
.
nickname
;
}
if
(
!
isEqual
(
user
.
username
,
state
.
username
))
{
userPatch
.
username
=
state
.
username
;
}
if
(
!
isEqual
(
user
.
email
,
state
.
email
))
{
userPatch
.
email
=
state
.
email
;
}
await
userService
.
patchUser
(
userPatch
);
toastHelper
.
info
(
"Update succeed"
);
handleCloseBtnClick
();
}
catch
(
error
:
any
)
{
...
...
web/src/components/UserBanner.tsx
View file @
b511a7b6
...
...
@@ -76,7 +76,7 @@ const UserBanner = () => {
</
div
>
<
Dropdown
trigger=
{
<
Icon
.
MoreHorizontal
className=
"ml-2 w-5 h-auto cursor-pointer"
/>
}
actionsClassName=
"
!
w-36"
actionsClassName=
"
min-
w-36"
actions=
{
<>
{
!
userService
.
isVisitorMode
()
&&
(
...
...
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