mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 01:04:25 +08:00
make user enter current password when modifying password
This commit is contained in:
+10
-2
@@ -131,8 +131,16 @@ func (a *UsersApi) UserUpdateProfileHandler(c *core.Context) (interface{}, *errs
|
|||||||
userUpdateReq.Email = ""
|
userUpdateReq.Email = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
if userUpdateReq.Password != "" && !a.users.IsPasswordEqualsUserPassword(userUpdateReq.Password, user) {
|
if userUpdateReq.Password != "" {
|
||||||
anythingUpdate = true
|
if !a.users.IsPasswordEqualsUserPassword(userUpdateReq.OldPassword, user) {
|
||||||
|
return nil, errs.ErrUserPasswordWrong
|
||||||
|
}
|
||||||
|
|
||||||
|
if !a.users.IsPasswordEqualsUserPassword(userUpdateReq.Password, user) {
|
||||||
|
anythingUpdate = true
|
||||||
|
} else {
|
||||||
|
userUpdateReq.Password = ""
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
userUpdateReq.Password = ""
|
userUpdateReq.Password = ""
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-3
@@ -39,9 +39,10 @@ type UserRegisterRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UserProfileUpdateRequest struct {
|
type UserProfileUpdateRequest struct {
|
||||||
Email string `json:"email" binding:"omitempty,notBlank,max=100,validEmail"`
|
Email string `json:"email" binding:"omitempty,notBlank,max=100,validEmail"`
|
||||||
Nickname string `json:"nickname" binding:"omitempty,notBlank,max=64"`
|
Nickname string `json:"nickname" binding:"omitempty,notBlank,max=64"`
|
||||||
Password string `json:"password" binding:"omitempty,min=6,max=128"`
|
Password string `json:"password" binding:"omitempty,min=6,max=128"`
|
||||||
|
OldPassword string `json:"oldPassword" binding:"omitempty,min=6,max=128"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserProfileResponse struct {
|
type UserProfileResponse struct {
|
||||||
|
|||||||
+3
-2
@@ -127,11 +127,12 @@ export default {
|
|||||||
getProfile: () => {
|
getProfile: () => {
|
||||||
return axios.get('v1/users/profile/get.json');
|
return axios.get('v1/users/profile/get.json');
|
||||||
},
|
},
|
||||||
updateProfile: ({ email, nickname, password }) => {
|
updateProfile: ({ email, nickname, password, oldPassword }) => {
|
||||||
return axios.post('v1/users/profile/update.json', {
|
return axios.post('v1/users/profile/update.json', {
|
||||||
email,
|
email,
|
||||||
nickname,
|
nickname,
|
||||||
password
|
password,
|
||||||
|
oldPassword
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ export default {
|
|||||||
'password': 'Password',
|
'password': 'Password',
|
||||||
'email': 'Email',
|
'email': 'Email',
|
||||||
'nickname': 'Nickname',
|
'nickname': 'Nickname',
|
||||||
|
'oldPassword': 'Current Password',
|
||||||
},
|
},
|
||||||
'parameterizedError': {
|
'parameterizedError': {
|
||||||
'parameter invalid': '{parameter} is invalid',
|
'parameter invalid': '{parameter} is invalid',
|
||||||
@@ -64,6 +65,7 @@ export default {
|
|||||||
'Close': 'Close',
|
'Close': 'Close',
|
||||||
'Update': 'Update',
|
'Update': 'Update',
|
||||||
'Done': 'Done',
|
'Done': 'Done',
|
||||||
|
'Continue': 'Continue',
|
||||||
'Version': 'Version',
|
'Version': 'Version',
|
||||||
'User': 'User',
|
'User': 'User',
|
||||||
'Application': 'Application',
|
'Application': 'Application',
|
||||||
@@ -113,6 +115,8 @@ export default {
|
|||||||
'Unable to sign up': 'Unable to sign up',
|
'Unable to sign up': 'Unable to sign up',
|
||||||
'User registration is disabled': 'User registration is disabled',
|
'User registration is disabled': 'User registration is disabled',
|
||||||
'Unable to get user profile': 'Unable to get user profile',
|
'Unable to get user profile': 'Unable to get user profile',
|
||||||
|
'Current Password': 'Current Password',
|
||||||
|
'Please enter your current password when modifying your password': 'Please enter your current password when modifying your password',
|
||||||
'Nothing has been modified': 'Nothing has been modified',
|
'Nothing has been modified': 'Nothing has been modified',
|
||||||
'Your profile has been successfully updated': 'Your profile has been successfully updated',
|
'Your profile has been successfully updated': 'Your profile has been successfully updated',
|
||||||
'Unable to update user profile': 'Unable to update user profile',
|
'Unable to update user profile': 'Unable to update user profile',
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ export default {
|
|||||||
'password': '密码',
|
'password': '密码',
|
||||||
'email': '电子邮箱',
|
'email': '电子邮箱',
|
||||||
'nickname': '昵称',
|
'nickname': '昵称',
|
||||||
|
'oldPassword': '当前密码',
|
||||||
},
|
},
|
||||||
'parameterizedError': {
|
'parameterizedError': {
|
||||||
'parameter invalid': '{parameter}无效',
|
'parameter invalid': '{parameter}无效',
|
||||||
@@ -64,6 +65,7 @@ export default {
|
|||||||
'Close': '关闭',
|
'Close': '关闭',
|
||||||
'Update': '更新',
|
'Update': '更新',
|
||||||
'Done': '完成',
|
'Done': '完成',
|
||||||
|
'Continue': '继续',
|
||||||
'Version': '版本',
|
'Version': '版本',
|
||||||
'User': '用户',
|
'User': '用户',
|
||||||
'Application': '应用',
|
'Application': '应用',
|
||||||
@@ -113,6 +115,8 @@ export default {
|
|||||||
'Unable to sign up': '无法注册',
|
'Unable to sign up': '无法注册',
|
||||||
'User registration is disabled': '用户注册已禁用',
|
'User registration is disabled': '用户注册已禁用',
|
||||||
'Unable to get user profile': '无法获取用户信息',
|
'Unable to get user profile': '无法获取用户信息',
|
||||||
|
'Current Password': '当前密码',
|
||||||
|
'Please enter your current password when modifying your password': '修改密码时请输入您的当前密码',
|
||||||
'Nothing has been modified': '没有修改的项目',
|
'Nothing has been modified': '没有修改的项目',
|
||||||
'Your profile has been successfully updated': '您的用户信息更新成功',
|
'Your profile has been successfully updated': '您的用户信息更新成功',
|
||||||
'Unable to update user profile': '无法更新用户信息',
|
'Unable to update user profile': '无法更新用户信息',
|
||||||
|
|||||||
@@ -42,6 +42,32 @@
|
|||||||
</f7-list>
|
</f7-list>
|
||||||
|
|
||||||
<f7-button large fill :class="{ 'disabled': inputIsNotChanged }" :text="$t('Update')" @click="update"></f7-button>
|
<f7-button large fill :class="{ 'disabled': inputIsNotChanged }" :text="$t('Update')" @click="update"></f7-button>
|
||||||
|
|
||||||
|
<f7-sheet
|
||||||
|
style="height:auto; --f7-sheet-bg-color: #fff;"
|
||||||
|
backdrop
|
||||||
|
:opened="showInputPasswordSheet" @sheet:closed="showInputPasswordSheet = false"
|
||||||
|
>
|
||||||
|
<div class="sheet-modal-swipe-step">
|
||||||
|
<div class="display-flex padding justify-content-space-between align-items-center">
|
||||||
|
<div style="font-size: 18px"><b v-t="'Current Password'"></b></div>
|
||||||
|
</div>
|
||||||
|
<div class="padding-horizontal padding-bottom">
|
||||||
|
<p class="input-password-tips">{{ $t('Please enter your current password when modifying your password') }}</p>
|
||||||
|
<f7-list no-hairlines class="input-password-form">
|
||||||
|
<f7-list-input
|
||||||
|
type="password"
|
||||||
|
outline
|
||||||
|
clear-button
|
||||||
|
:placeholder="$t('Password')"
|
||||||
|
:value="currentPassword"
|
||||||
|
@input="currentPassword = $event.target.value"
|
||||||
|
></f7-list-input>
|
||||||
|
</f7-list>
|
||||||
|
<f7-button large fill :class="{ 'disabled': !currentPassword }" :text="$t('Continue')" @click="update"></f7-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</f7-sheet>
|
||||||
</f7-page>
|
</f7-page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -49,12 +75,14 @@
|
|||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
currentPassword: '',
|
||||||
password: '',
|
password: '',
|
||||||
confirmPassword: '',
|
confirmPassword: '',
|
||||||
oldEmail: '',
|
oldEmail: '',
|
||||||
email: '',
|
email: '',
|
||||||
oldNickname: '',
|
oldNickname: '',
|
||||||
nickname: ''
|
nickname: '',
|
||||||
|
showInputPasswordSheet: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -128,6 +156,8 @@ export default {
|
|||||||
const app = self.$f7;
|
const app = self.$f7;
|
||||||
const router = self.$f7router;
|
const router = self.$f7router;
|
||||||
|
|
||||||
|
self.showInputPasswordSheet = false;
|
||||||
|
|
||||||
let problemMessage = self.inputIsNotChangedProblemMessage || self.inputInvalidProblemMessage;
|
let problemMessage = self.inputIsNotChangedProblemMessage || self.inputInvalidProblemMessage;
|
||||||
|
|
||||||
if (problemMessage) {
|
if (problemMessage) {
|
||||||
@@ -135,6 +165,11 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (self.password && !self.currentPassword) {
|
||||||
|
self.showInputPasswordSheet = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let hasResponse = false;
|
let hasResponse = false;
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -145,11 +180,14 @@ export default {
|
|||||||
|
|
||||||
self.$services.updateProfile({
|
self.$services.updateProfile({
|
||||||
password: self.password,
|
password: self.password,
|
||||||
|
oldPassword: self.currentPassword,
|
||||||
email: self.email,
|
email: self.email,
|
||||||
nickname: self.nickname
|
nickname: self.nickname
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
hasResponse = true;
|
hasResponse = true;
|
||||||
app.preloader.hide();
|
app.preloader.hide();
|
||||||
|
self.currentPassword = '';
|
||||||
|
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
|
|
||||||
if (!data || !data.success || !data.result) {
|
if (!data || !data.success || !data.result) {
|
||||||
@@ -170,6 +208,7 @@ export default {
|
|||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
hasResponse = true;
|
hasResponse = true;
|
||||||
app.preloader.hide();
|
app.preloader.hide();
|
||||||
|
self.currentPassword = '';
|
||||||
|
|
||||||
if (error.response && error.response.data && error.response.data.errorMessage) {
|
if (error.response && error.response.data && error.response.data.errorMessage) {
|
||||||
self.$alert({ error: error.response.data });
|
self.$alert({ error: error.response.data });
|
||||||
@@ -181,3 +220,14 @@ export default {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.input-password-tips {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-password-form {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user