feat: now supports custom smtp port
This commit is contained in:
parent
9edc54ca69
commit
5c694a1503
@ -34,6 +34,7 @@ var TurnstileCheckEnabled = false
|
||||
var RegisterEnabled = true
|
||||
|
||||
var SMTPServer = ""
|
||||
var SMTPPort = 587
|
||||
var SMTPAccount = ""
|
||||
var SMTPToken = ""
|
||||
|
||||
|
@ -8,7 +8,7 @@ func SendEmail(subject string, receiver string, content string) error {
|
||||
m.SetHeader("To", receiver)
|
||||
m.SetHeader("Subject", subject)
|
||||
m.SetBody("text/html", content)
|
||||
d := gomail.NewDialer(SMTPServer, 587, SMTPAccount, SMTPToken)
|
||||
d := gomail.NewDialer(SMTPServer, SMTPPort, SMTPAccount, SMTPToken)
|
||||
err := d.DialAndSend(m)
|
||||
return err
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ func InitOptionMap() {
|
||||
common.OptionMap["TurnstileCheckEnabled"] = strconv.FormatBool(common.TurnstileCheckEnabled)
|
||||
common.OptionMap["RegisterEnabled"] = strconv.FormatBool(common.RegisterEnabled)
|
||||
common.OptionMap["SMTPServer"] = ""
|
||||
common.OptionMap["SMTPPort"] = strconv.Itoa(common.SMTPPort)
|
||||
common.OptionMap["SMTPAccount"] = ""
|
||||
common.OptionMap["SMTPToken"] = ""
|
||||
common.OptionMap["Notice"] = ""
|
||||
@ -112,6 +113,9 @@ func updateOptionMap(key string, value string) (err error) {
|
||||
switch key {
|
||||
case "SMTPServer":
|
||||
common.SMTPServer = value
|
||||
case "SMTPPort":
|
||||
intValue, _ := strconv.Atoi(value)
|
||||
common.SMTPPort = intValue
|
||||
case "SMTPAccount":
|
||||
common.SMTPAccount = value
|
||||
case "SMTPToken":
|
||||
|
@ -12,6 +12,7 @@ const SystemSetting = () => {
|
||||
GitHubClientSecret: '',
|
||||
Notice: '',
|
||||
SMTPServer: '',
|
||||
SMTPPort: '',
|
||||
SMTPAccount: '',
|
||||
SMTPToken: '',
|
||||
ServerAddress: '',
|
||||
@ -128,6 +129,12 @@ const SystemSetting = () => {
|
||||
if (originInputs['SMTPAccount'] !== inputs.SMTPAccount) {
|
||||
await updateOption('SMTPAccount', inputs.SMTPAccount);
|
||||
}
|
||||
if (
|
||||
originInputs['SMTPPort'] !== inputs.SMTPPort &&
|
||||
inputs.SMTPPort !== ''
|
||||
) {
|
||||
await updateOption('SMTPPort', inputs.SMTPPort);
|
||||
}
|
||||
if (
|
||||
originInputs['SMTPToken'] !== inputs.SMTPToken &&
|
||||
inputs.SMTPToken !== ''
|
||||
@ -258,7 +265,7 @@ const SystemSetting = () => {
|
||||
label='新用户初始配额'
|
||||
name='QuotaForNewUser'
|
||||
onChange={handleInputChange}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
value={inputs.QuotaForNewUser}
|
||||
type='number'
|
||||
min='0'
|
||||
@ -268,7 +275,7 @@ const SystemSetting = () => {
|
||||
label='充值链接'
|
||||
name='TopUpLink'
|
||||
onChange={handleInputChange}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
value={inputs.TopUpLink}
|
||||
type='link'
|
||||
placeholder='例如发卡网站的购买链接'
|
||||
@ -280,7 +287,7 @@ const SystemSetting = () => {
|
||||
name='ModelRatio'
|
||||
onChange={handleInputChange}
|
||||
style={{ minHeight: 250, fontFamily: 'JetBrains Mono, Consolas' }}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
value={inputs.ModelRatio}
|
||||
placeholder='为一个 JSON 文本,键为模型名称,值为倍率'
|
||||
/>
|
||||
@ -291,20 +298,28 @@ const SystemSetting = () => {
|
||||
配置 SMTP
|
||||
<Header.Subheader>用以支持系统的邮件发送</Header.Subheader>
|
||||
</Header>
|
||||
<Form.Group widths={3}>
|
||||
<Form.Group widths={4}>
|
||||
<Form.Input
|
||||
label='SMTP 服务器地址'
|
||||
name='SMTPServer'
|
||||
onChange={handleInputChange}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
value={inputs.SMTPServer}
|
||||
placeholder='例如:smtp.qq.com'
|
||||
/>
|
||||
<Form.Input
|
||||
label='SMTP 端口'
|
||||
name='SMTPPort'
|
||||
onChange={handleInputChange}
|
||||
autoComplete='new-password'
|
||||
value={inputs.SMTPPort}
|
||||
placeholder='默认: 587'
|
||||
/>
|
||||
<Form.Input
|
||||
label='SMTP 账户'
|
||||
name='SMTPAccount'
|
||||
onChange={handleInputChange}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
value={inputs.SMTPAccount}
|
||||
placeholder='通常是邮箱地址'
|
||||
/>
|
||||
@ -313,7 +328,7 @@ const SystemSetting = () => {
|
||||
name='SMTPToken'
|
||||
onChange={handleInputChange}
|
||||
type='password'
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
value={inputs.SMTPToken}
|
||||
placeholder='敏感信息不会发送到前端显示'
|
||||
/>
|
||||
@ -340,7 +355,7 @@ const SystemSetting = () => {
|
||||
label='GitHub Client ID'
|
||||
name='GitHubClientId'
|
||||
onChange={handleInputChange}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
value={inputs.GitHubClientId}
|
||||
placeholder='输入你注册的 GitHub OAuth APP 的 ID'
|
||||
/>
|
||||
@ -349,7 +364,7 @@ const SystemSetting = () => {
|
||||
name='GitHubClientSecret'
|
||||
onChange={handleInputChange}
|
||||
type='password'
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
value={inputs.GitHubClientSecret}
|
||||
placeholder='敏感信息不会发送到前端显示'
|
||||
/>
|
||||
@ -377,7 +392,7 @@ const SystemSetting = () => {
|
||||
name='WeChatServerAddress'
|
||||
placeholder='例如:https://yourdomain.com'
|
||||
onChange={handleInputChange}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
value={inputs.WeChatServerAddress}
|
||||
/>
|
||||
<Form.Input
|
||||
@ -385,7 +400,7 @@ const SystemSetting = () => {
|
||||
name='WeChatServerToken'
|
||||
type='password'
|
||||
onChange={handleInputChange}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
value={inputs.WeChatServerToken}
|
||||
placeholder='敏感信息不会发送到前端显示'
|
||||
/>
|
||||
@ -393,7 +408,7 @@ const SystemSetting = () => {
|
||||
label='微信公众号二维码图片链接'
|
||||
name='WeChatAccountQRCodeImageURL'
|
||||
onChange={handleInputChange}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
value={inputs.WeChatAccountQRCodeImageURL}
|
||||
placeholder='输入一个图片链接'
|
||||
/>
|
||||
@ -417,7 +432,7 @@ const SystemSetting = () => {
|
||||
label='Turnstile Site Key'
|
||||
name='TurnstileSiteKey'
|
||||
onChange={handleInputChange}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
value={inputs.TurnstileSiteKey}
|
||||
placeholder='输入你注册的 Turnstile Site Key'
|
||||
/>
|
||||
@ -426,7 +441,7 @@ const SystemSetting = () => {
|
||||
name='TurnstileSecretKey'
|
||||
onChange={handleInputChange}
|
||||
type='password'
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
value={inputs.TurnstileSecretKey}
|
||||
placeholder='敏感信息不会发送到前端显示'
|
||||
/>
|
||||
|
@ -36,7 +36,7 @@ const AddChannel = () => {
|
||||
<>
|
||||
<Segment>
|
||||
<Header as='h3'>创建新的渠道</Header>
|
||||
<Form autoComplete='off'>
|
||||
<Form autoComplete='new-password'>
|
||||
<Form.Field>
|
||||
<Form.Select
|
||||
label='类型'
|
||||
@ -55,7 +55,7 @@ const AddChannel = () => {
|
||||
placeholder={'请输入自定义渠道的 Base URL,例如:https://openai.justsong.cn'}
|
||||
onChange={handleInputChange}
|
||||
value={inputs.base_url}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
/>
|
||||
</Form.Field>
|
||||
)
|
||||
@ -67,7 +67,7 @@ const AddChannel = () => {
|
||||
placeholder={'请输入名称'}
|
||||
onChange={handleInputChange}
|
||||
value={name}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
required
|
||||
/>
|
||||
</Form.Field>
|
||||
@ -79,7 +79,7 @@ const AddChannel = () => {
|
||||
onChange={handleInputChange}
|
||||
value={key}
|
||||
// type='password'
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
required
|
||||
/>
|
||||
</Form.Field>
|
||||
|
@ -50,7 +50,7 @@ const EditChannel = () => {
|
||||
<>
|
||||
<Segment loading={loading}>
|
||||
<Header as='h3'>更新渠道信息</Header>
|
||||
<Form autoComplete='off'>
|
||||
<Form autoComplete='new-password'>
|
||||
<Form.Field>
|
||||
<Form.Select
|
||||
label='类型'
|
||||
@ -69,7 +69,7 @@ const EditChannel = () => {
|
||||
placeholder={'请输入新的自定义渠道的 Base URL,例如:https://openai.justsong.cn'}
|
||||
onChange={handleInputChange}
|
||||
value={inputs.base_url}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
/>
|
||||
</Form.Field>
|
||||
)
|
||||
@ -81,7 +81,7 @@ const EditChannel = () => {
|
||||
placeholder={'请输入新的名称'}
|
||||
onChange={handleInputChange}
|
||||
value={inputs.name}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
/>
|
||||
</Form.Field>
|
||||
<Form.Field>
|
||||
@ -92,7 +92,7 @@ const EditChannel = () => {
|
||||
onChange={handleInputChange}
|
||||
value={inputs.key}
|
||||
// type='password'
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
/>
|
||||
</Form.Field>
|
||||
<Button onClick={submit}>提交</Button>
|
||||
|
@ -73,7 +73,7 @@ const EditRedemption = () => {
|
||||
<>
|
||||
<Segment loading={loading}>
|
||||
<Header as='h3'>{isEdit ? '更新兑换码信息' : '创建新的兑换码'}</Header>
|
||||
<Form autoComplete='off'>
|
||||
<Form autoComplete='new-password'>
|
||||
<Form.Field>
|
||||
<Form.Input
|
||||
label='名称'
|
||||
@ -81,7 +81,7 @@ const EditRedemption = () => {
|
||||
placeholder={'请输入名称'}
|
||||
onChange={handleInputChange}
|
||||
value={name}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
required={!isEdit}
|
||||
/>
|
||||
</Form.Field>
|
||||
@ -92,7 +92,7 @@ const EditRedemption = () => {
|
||||
placeholder={'请输入单个兑换码中包含的额度'}
|
||||
onChange={handleInputChange}
|
||||
value={quota}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
type='number'
|
||||
/>
|
||||
</Form.Field>
|
||||
@ -105,7 +105,7 @@ const EditRedemption = () => {
|
||||
placeholder={'请输入生成数量'}
|
||||
onChange={handleInputChange}
|
||||
value={count}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
type='number'
|
||||
/>
|
||||
</Form.Field>
|
||||
|
@ -95,7 +95,7 @@ const EditToken = () => {
|
||||
<>
|
||||
<Segment loading={loading}>
|
||||
<Header as='h3'>{isEdit ? '更新令牌信息' : '创建新的令牌'}</Header>
|
||||
<Form autoComplete='off'>
|
||||
<Form autoComplete='new-password'>
|
||||
<Form.Field>
|
||||
<Form.Input
|
||||
label='名称'
|
||||
@ -103,7 +103,7 @@ const EditToken = () => {
|
||||
placeholder={'请输入名称'}
|
||||
onChange={handleInputChange}
|
||||
value={name}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
required={!isEdit}
|
||||
/>
|
||||
</Form.Field>
|
||||
@ -116,7 +116,7 @@ const EditToken = () => {
|
||||
placeholder={'请输入额度'}
|
||||
onChange={handleInputChange}
|
||||
value={remain_quota}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
type='number'
|
||||
disabled={unlimited_quota}
|
||||
/>
|
||||
@ -133,7 +133,7 @@ const EditToken = () => {
|
||||
placeholder={'请输入过期时间,格式为 yyyy-MM-dd HH:mm:ss,-1 表示无限制'}
|
||||
onChange={handleInputChange}
|
||||
value={expired_time}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
type='datetime-local'
|
||||
/>
|
||||
</Form.Field>
|
||||
|
@ -60,7 +60,7 @@ const EditUser = () => {
|
||||
<>
|
||||
<Segment loading={loading}>
|
||||
<Header as='h3'>更新用户信息</Header>
|
||||
<Form autoComplete='off'>
|
||||
<Form autoComplete='new-password'>
|
||||
<Form.Field>
|
||||
<Form.Input
|
||||
label='用户名'
|
||||
@ -68,7 +68,7 @@ const EditUser = () => {
|
||||
placeholder={'请输入新的用户名'}
|
||||
onChange={handleInputChange}
|
||||
value={username}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
/>
|
||||
</Form.Field>
|
||||
<Form.Field>
|
||||
@ -79,7 +79,7 @@ const EditUser = () => {
|
||||
placeholder={'请输入新的密码'}
|
||||
onChange={handleInputChange}
|
||||
value={password}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
/>
|
||||
</Form.Field>
|
||||
<Form.Field>
|
||||
@ -89,7 +89,7 @@ const EditUser = () => {
|
||||
placeholder={'请输入新的显示名称'}
|
||||
onChange={handleInputChange}
|
||||
value={display_name}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
/>
|
||||
</Form.Field>
|
||||
<Form.Field>
|
||||
@ -97,7 +97,7 @@ const EditUser = () => {
|
||||
label='已绑定的 GitHub 账户'
|
||||
name='github_id'
|
||||
value={github_id}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
placeholder='此项只读,需要用户通过个人设置页面的相关绑定按钮进行绑定,不可直接修改'
|
||||
readOnly
|
||||
/>
|
||||
@ -107,7 +107,7 @@ const EditUser = () => {
|
||||
label='已绑定的微信账户'
|
||||
name='wechat_id'
|
||||
value={wechat_id}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
placeholder='此项只读,需要用户通过个人设置页面的相关绑定按钮进行绑定,不可直接修改'
|
||||
readOnly
|
||||
/>
|
||||
@ -117,7 +117,7 @@ const EditUser = () => {
|
||||
label='已绑定的邮箱账户'
|
||||
name='email'
|
||||
value={email}
|
||||
autoComplete='off'
|
||||
autoComplete='new-password'
|
||||
placeholder='此项只读,需要用户通过个人设置页面的相关绑定按钮进行绑定,不可直接修改'
|
||||
readOnly
|
||||
/>
|
||||
|
Loading…
Reference in New Issue
Block a user