mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-12 02:45:49 +02:00
fix(user):register duplicate name
This commit is contained in:
parent
d73ee1f035
commit
e04773a409
1 changed files with 8 additions and 0 deletions
|
@ -57,6 +57,14 @@ func AddUser(c *gin.Context) {
|
||||||
Password: json.Password,
|
Password: json.Password,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// duplicate name
|
||||||
|
_, err = u.Where(u.Name.Eq(json.Name)).First()
|
||||||
|
if !(err != nil && err.Error() == "record not found") {
|
||||||
|
c.JSON(http.StatusConflict, gin.H{
|
||||||
|
"message": "name already exists",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
err = u.Create(&user)
|
err = u.Create(&user)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue