mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-06 09:50:28 +08:00
feat: support links in email to reset password (#3939)
This commit is contained in:
@@ -1227,7 +1227,7 @@ class ProviderEditPage extends React.Component {
|
||||
</Col>
|
||||
<Col span={22} >
|
||||
<Row style={{marginTop: "20px"}} >
|
||||
<Button style={{marginLeft: "10px", marginBottom: "5px"}} onClick={() => this.updateProviderField("content", "You have requested a verification code at Casdoor. Here is your code: %s, please enter in 5 minutes.")} >
|
||||
<Button style={{marginLeft: "10px", marginBottom: "5px"}} onClick={() => this.updateProviderField("content", "You have requested a verification code at Casdoor. Here is your code: %s, please enter in 5 minutes. <reset-link>Or click %link to reset</reset-link>")} >
|
||||
{i18next.t("provider:Reset to Default Text")}
|
||||
</Button>
|
||||
<Button style={{marginLeft: "10px", marginBottom: "5px"}} type="primary" onClick={() => this.updateProviderField("content", Setting.getDefaultHtmlEmailContent())} >
|
||||
|
@@ -1580,6 +1580,11 @@ export function getDefaultHtmlEmailContent() {
|
||||
<div class="code">
|
||||
%s
|
||||
</div>
|
||||
<reset-link>
|
||||
<div class="link">
|
||||
Or click this <a href="%link">link</a> to reset
|
||||
</div>
|
||||
</reset-link>
|
||||
<p>Thanks</p>
|
||||
<p>Casbin Team</p>
|
||||
<hr>
|
||||
|
@@ -31,18 +31,21 @@ const {Option} = Select;
|
||||
class ForgetPage extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
const queryParams = new URLSearchParams(location.search);
|
||||
this.state = {
|
||||
classes: props,
|
||||
applicationName: props.applicationName ?? props.match.params?.applicationName,
|
||||
msg: null,
|
||||
name: props.account ? props.account.name : "",
|
||||
name: props.account ? props.account.name : queryParams.get("username"),
|
||||
username: props.account ? props.account.name : "",
|
||||
phone: "",
|
||||
email: "",
|
||||
dest: "",
|
||||
isVerifyTypeFixed: false,
|
||||
verifyType: "", // "email", "phone"
|
||||
current: 0,
|
||||
current: queryParams.get("code") ? 2 : 0,
|
||||
code: queryParams.get("code"),
|
||||
queryParams: queryParams,
|
||||
};
|
||||
this.form = React.createRef();
|
||||
}
|
||||
@@ -148,9 +151,26 @@ class ForgetPage extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
onFinish(values) {
|
||||
async onFinish(values) {
|
||||
values.username = this.state.name;
|
||||
values.userOwner = this.getApplicationObj()?.organizationObj.name;
|
||||
|
||||
if (this.state.queryParams.get("code")) {
|
||||
const res = await UserBackend.verifyCode({
|
||||
application: this.getApplicationObj().name,
|
||||
organization: values.userOwner,
|
||||
username: this.state.queryParams.get("dest"),
|
||||
name: this.state.name,
|
||||
code: this.state.code,
|
||||
type: "login",
|
||||
});
|
||||
|
||||
if (res.status !== "ok") {
|
||||
Setting.showMessage("error", res.msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
UserBackend.setPassword(values.userOwner, values.username, "", values?.newPassword, this.state.code).then(res => {
|
||||
if (res.status === "ok") {
|
||||
const linkInStorage = sessionStorage.getItem("signinUrl");
|
||||
|
Reference in New Issue
Block a user