mirror of https://github.com/bjdgyc/anylink.git
修复 关闭otp时,发送邮件附件的问题
This commit is contained in:
parent
380a8cb3fb
commit
26483533a9
|
@ -214,6 +214,7 @@ type userAccountMailData struct {
|
|||
PinCode string
|
||||
OtpImg string
|
||||
OtpImgBase64 string
|
||||
DisableOtp bool
|
||||
}
|
||||
|
||||
func userAccountMail(user *dbdata.User) error {
|
||||
|
@ -265,6 +266,7 @@ func userAccountMail(user *dbdata.User) error {
|
|||
PinCode: user.PinCode,
|
||||
OtpImg: fmt.Sprintf("https://%s/otp_qr?id=%d&jwt=%s", setting.LinkAddr, user.Id, tokenString),
|
||||
OtpImgBase64: "data:image/png;base64," + otpData,
|
||||
DisableOtp: user.DisableOtp,
|
||||
}
|
||||
w := bytes.NewBufferString("")
|
||||
t, _ := template.New("auth_complete").Parse(htmlBody)
|
||||
|
@ -273,12 +275,18 @@ func userAccountMail(user *dbdata.User) error {
|
|||
return err
|
||||
}
|
||||
// fmt.Println(w.String())
|
||||
imgData, _ := userOtpQr(user.Id, false)
|
||||
attach := &mail.File{
|
||||
MimeType: "image/png",
|
||||
Name: "userOtpQr.png",
|
||||
Data: []byte(imgData),
|
||||
Inline: true,
|
||||
|
||||
var attach *mail.File
|
||||
if user.DisableOtp {
|
||||
attach = nil
|
||||
} else {
|
||||
imgData, _ := userOtpQr(user.Id, false)
|
||||
attach = &mail.File{
|
||||
MimeType: "image/png",
|
||||
Name: "userOtpQr.png",
|
||||
Data: []byte(imgData),
|
||||
Inline: true,
|
||||
}
|
||||
}
|
||||
|
||||
return SendMail(base.Cfg.Issuer, user.Email, w.String(), attach)
|
||||
|
|
|
@ -174,6 +174,9 @@ func CheckErrNotFound(err error) bool {
|
|||
return err == ErrNotFound
|
||||
}
|
||||
|
||||
// base64 图片
|
||||
// 用户动态码(请妥善保存):<br/>
|
||||
// <img src="{{.OtpImgBase64}}"/><br/>
|
||||
const accountMail = `<p>您好:</p>
|
||||
<p> 您的{{.Issuer}}账号已经审核开通。</p>
|
||||
<p>
|
||||
|
@ -181,17 +184,18 @@ const accountMail = `<p>您好:</p>
|
|||
用户组: <b>{{.Group}}</b> <br/>
|
||||
用户名: <b>{{.Username}}</b> <br/>
|
||||
用户PIN码: <b>{{.PinCode}}</b> <br/>
|
||||
{{if .DisableOtp}}
|
||||
<!-- nothing -->
|
||||
{{else}}
|
||||
|
||||
<!--
|
||||
用户动态码(3天后失效):<br/>
|
||||
<img src="{{.OtpImg}}"/><br/>
|
||||
|
||||
用户动态码(请妥善保存):<br/>
|
||||
<img src="{{.OtpImgBase64}}"/><br/>
|
||||
|
||||
下面是兼容 gmail 的写法
|
||||
-->
|
||||
用户动态码(请妥善保存):<br/>
|
||||
<img src="cid:userOtpQr.png" alt="userOtpQr" /><br/>
|
||||
|
||||
{{end}}
|
||||
</p>
|
||||
<div>
|
||||
使用说明:
|
||||
|
|
Loading…
Reference in New Issue