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
be27c00d
authored
Dec 20, 2023
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
个人设置添加修改密码功能
parent
1baf092c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
1 deletions
+62
-1
web/src/components/PersonalSetting.js
+62
-1
No files found.
web/src/components/PersonalSetting.js
View file @
be27c00d
...
@@ -20,6 +20,7 @@ import {
...
@@ -20,6 +20,7 @@ import {
import
{
getQuotaPerUnit
,
renderQuota
,
renderQuotaWithPrompt
,
stringToColor
}
from
"../helpers/render"
;
import
{
getQuotaPerUnit
,
renderQuota
,
renderQuotaWithPrompt
,
stringToColor
}
from
"../helpers/render"
;
import
EditToken
from
"../pages/Token/EditToken"
;
import
EditToken
from
"../pages/Token/EditToken"
;
import
EditUser
from
"../pages/User/EditUser"
;
import
EditUser
from
"../pages/User/EditUser"
;
import
passwordResetConfirm
from
"./PasswordResetConfirm"
;
const
PersonalSetting
=
()
=>
{
const
PersonalSetting
=
()
=>
{
const
[
userState
,
userDispatch
]
=
useContext
(
UserContext
);
const
[
userState
,
userDispatch
]
=
useContext
(
UserContext
);
...
@@ -29,9 +30,12 @@ const PersonalSetting = () => {
...
@@ -29,9 +30,12 @@ const PersonalSetting = () => {
wechat_verification_code
:
''
,
wechat_verification_code
:
''
,
email_verification_code
:
''
,
email_verification_code
:
''
,
email
:
''
,
email
:
''
,
self_account_deletion_confirmation
:
''
self_account_deletion_confirmation
:
''
,
set_new_password
:
''
,
set_new_password_confirmation
:
''
,
});
});
const
[
status
,
setStatus
]
=
useState
({});
const
[
status
,
setStatus
]
=
useState
({});
const
[
showChangePasswordModal
,
setShowChangePasswordModal
]
=
useState
(
false
);
const
[
showWeChatBindModal
,
setShowWeChatBindModal
]
=
useState
(
false
);
const
[
showWeChatBindModal
,
setShowWeChatBindModal
]
=
useState
(
false
);
const
[
showEmailBindModal
,
setShowEmailBindModal
]
=
useState
(
false
);
const
[
showEmailBindModal
,
setShowEmailBindModal
]
=
useState
(
false
);
const
[
showAccountDeleteModal
,
setShowAccountDeleteModal
]
=
useState
(
false
);
const
[
showAccountDeleteModal
,
setShowAccountDeleteModal
]
=
useState
(
false
);
...
@@ -180,6 +184,27 @@ const PersonalSetting = () => {
...
@@ -180,6 +184,27 @@ const PersonalSetting = () => {
}
}
};
};
const
changePassword
=
async
()
=>
{
if
(
inputs
.
set_new_password
!==
inputs
.
set_new_password_confirmation
)
{
showError
(
'两次输入的密码不一致!'
);
return
;
}
const
res
=
await
API
.
put
(
`/api/user/self`
,
{
password
:
inputs
.
set_new_password
}
);
const
{
success
,
message
}
=
res
.
data
;
if
(
success
)
{
showSuccess
(
'密码修改成功!'
);
setShowWeChatBindModal
(
false
);
}
else
{
showError
(
message
);
}
setShowChangePasswordModal
(
false
);
};
const
transfer
=
async
()
=>
{
const
transfer
=
async
()
=>
{
if
(
transferAmount
<
getQuotaPerUnit
())
{
if
(
transferAmount
<
getQuotaPerUnit
())
{
showError
(
'划转金额最低为'
+
renderQuota
(
getQuotaPerUnit
()));
showError
(
'划转金额最低为'
+
renderQuota
(
getQuotaPerUnit
()));
...
@@ -420,6 +445,9 @@ const PersonalSetting = () => {
...
@@ -420,6 +445,9 @@ const PersonalSetting = () => {
<Space>
<Space>
<Button onClick={generateAccessToken}>生成系统访问令牌</Button>
<Button onClick={generateAccessToken}>生成系统访问令牌</Button>
<Button onClick={() => {
<Button onClick={() => {
setShowChangePasswordModal(true);
}}>修改密码</Button>
<Button type={'danger'} onClick={() => {
setShowAccountDeleteModal(true);
setShowAccountDeleteModal(true);
}}>删除个人账户</Button>
}}>删除个人账户</Button>
</Space>
</Space>
...
@@ -543,6 +571,39 @@ const PersonalSetting = () => {
...
@@ -543,6 +571,39 @@ const PersonalSetting = () => {
)}
)}
</div>
</div>
</Modal>
</Modal>
<Modal
onCancel={() => setShowChangePasswordModal(false)}
visible={showChangePasswordModal}
size={'small'}
centered={true}
onOk={changePassword}
>
<div style={{marginTop: 20}}>
<Input
name='set_new_password'
placeholder='新密码'
value={inputs.set_new_password}
onChange={(value)=>handleInputChange('set_new_password', value)}
/>
<Input
style={{marginTop: 20}}
name='set_new_password_confirmation'
placeholder='确认新密码'
value={inputs.set_new_password_confirmation}
onChange={(value)=>handleInputChange('set_new_password_confirmation', value)}
/>
{turnstileEnabled ? (
<Turnstile
sitekey={turnstileSiteKey}
onVerify={(token) => {
setTurnstileToken(token);
}}
/>
) : (
<></>
)}
</div>
</Modal>
</div>
</div>
</Layout.Content>
</Layout.Content>
...
...
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