Add receiver for Email provider

This commit is contained in:
Gucheng Wang
2022-09-04 11:37:36 +08:00
parent b23bd0b189
commit d278bc9651
2 changed files with 8 additions and 10 deletions

View File

@ -48,6 +48,7 @@ type Provider struct {
DisableSsl bool `json:"disableSsl"` DisableSsl bool `json:"disableSsl"`
Title string `xorm:"varchar(100)" json:"title"` Title string `xorm:"varchar(100)" json:"title"`
Content string `xorm:"varchar(1000)" json:"content"` Content string `xorm:"varchar(1000)" json:"content"`
Receiver string `xorm:"varchar(100)" json:"receiver"`
RegionId string `xorm:"varchar(100)" json:"regionId"` RegionId string `xorm:"varchar(100)" json:"regionId"`
SignName string `xorm:"varchar(100)" json:"signName"` SignName string `xorm:"varchar(100)" json:"signName"`

View File

@ -34,7 +34,6 @@ class ProviderEditPage extends React.Component {
providerName: props.match.params.providerName, providerName: props.match.params.providerName,
provider: null, provider: null,
mode: props.location.mode !== undefined ? props.location.mode : "edit", mode: props.location.mode !== undefined ? props.location.mode : "edit",
testEmail: this.props.account["email"] !== undefined ? this.props.account["email"] : "",
}; };
} }
@ -207,6 +206,7 @@ class ProviderEditPage extends React.Component {
this.updateProviderField("disableSsl", false); this.updateProviderField("disableSsl", false);
this.updateProviderField("title", "Casdoor Verification Code"); this.updateProviderField("title", "Casdoor Verification Code");
this.updateProviderField("content", "You have requested a verification code at Casdoor. Here is your code: %s, please enter in 5 minutes."); this.updateProviderField("content", "You have requested a verification code at Casdoor. Here is your code: %s, please enter in 5 minutes.");
this.updateProviderField("receiver", this.props.account.email);
} else if (value === "SMS") { } else if (value === "SMS") {
this.updateProviderField("type", "Aliyun SMS"); this.updateProviderField("type", "Aliyun SMS");
} else if (value === "Storage") { } else if (value === "Storage") {
@ -551,19 +551,16 @@ class ProviderEditPage extends React.Component {
{Setting.getLabel(i18next.t("provider:Test Email"), i18next.t("provider:Test Email - Tooltip"))} : {Setting.getLabel(i18next.t("provider:Test Email"), i18next.t("provider:Test Email - Tooltip"))} :
</Col> </Col>
<Col span={4} > <Col span={4} >
<Input value={this.state.testEmail} <Input value={this.state.provider.receiver} placeholder = {i18next.t("user:Input your email")} onChange={e => {
placeholder = {i18next.t("user:Input your email")} this.updateProviderField("receiver", e.target.value);
onChange={e => { }} />
this.setState({testEmail: e.target.value});
}} />
</Col> </Col>
<Button style={{marginLeft: "10px", marginBottom: "5px"}} type="primary" <Button style={{marginLeft: "10px", marginBottom: "5px"}} type="primary" onClick={() => ProviderEditTestEmail.connectSmtpServer(this.state.provider)} >
onClick={() => ProviderEditTestEmail.connectSmtpServer(this.state.provider)} >
{i18next.t("provider:Test Connection")} {i18next.t("provider:Test Connection")}
</Button> </Button>
<Button style={{marginLeft: "10px", marginBottom: "5px"}} type="primary" <Button style={{marginLeft: "10px", marginBottom: "5px"}} type="primary"
disabled={!Setting.isValidEmail(this.state.testEmail)} disabled={!Setting.isValidEmail(this.state.provider.receiver)}
onClick={() => ProviderEditTestEmail.sendTestEmail(this.state.provider, this.state.testEmail)} > onClick={() => ProviderEditTestEmail.sendTestEmail(this.state.provider, this.state.provider.receiver)} >
{i18next.t("provider:Send Test Email")} {i18next.t("provider:Send Test Email")}
</Button> </Button>
</Row> </Row>