🔖 chore: prohibit users from modifying usernames
This commit is contained in:
parent
59d3b13311
commit
5ae57435ba
@ -415,8 +415,8 @@ func UpdateSelf(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanUser := model.User{
|
cleanUser := model.User{
|
||||||
Id: c.GetInt("id"),
|
Id: c.GetInt("id"),
|
||||||
Username: user.Username,
|
// Username: user.Username,
|
||||||
Password: user.Password,
|
Password: user.Password,
|
||||||
DisplayName: user.DisplayName,
|
DisplayName: user.DisplayName,
|
||||||
}
|
}
|
||||||
|
@ -139,9 +139,6 @@ func (user *User) Insert(inviterId int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (user *User) Update(updatePassword bool) error {
|
func (user *User) Update(updatePassword bool) error {
|
||||||
if RecordExists(&User{}, "username", user.Username, user.Id) {
|
|
||||||
return errors.New("用户名已存在!")
|
|
||||||
}
|
|
||||||
var err error
|
var err error
|
||||||
if updatePassword {
|
if updatePassword {
|
||||||
user.Password, err = common.Password2Hash(user.Password)
|
user.Password, err = common.Password2Hash(user.Password)
|
||||||
|
@ -107,7 +107,7 @@ export default function Profile() {
|
|||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
try {
|
try {
|
||||||
let inputValue = inputs;
|
let inputValue = inputs;
|
||||||
inputValue.username = trims(inputValue.username);
|
// inputValue.username = trims(inputValue.username);
|
||||||
inputValue.display_name = trims(inputValue.display_name);
|
inputValue.display_name = trims(inputValue.display_name);
|
||||||
await validationSchema.validate(inputValue);
|
await validationSchema.validate(inputValue);
|
||||||
const res = await API.put(`/api/user/self`, inputValue);
|
const res = await API.put(`/api/user/self`, inputValue);
|
||||||
@ -170,7 +170,8 @@ export default function Profile() {
|
|||||||
label="用户名"
|
label="用户名"
|
||||||
type="text"
|
type="text"
|
||||||
value={inputs.username || ''}
|
value={inputs.username || ''}
|
||||||
onChange={handleInputChange}
|
// onChange={handleInputChange}
|
||||||
|
disabled
|
||||||
name="username"
|
name="username"
|
||||||
placeholder="请输入用户名"
|
placeholder="请输入用户名"
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user