Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
78d878bc05
|
@ -1,4 +1,4 @@
|
|||
Subject: Please confirm your {{ .CompanyName }} account
|
||||
Subject: Confirm Email Address for {{ .CompanyName }} Account
|
||||
MIME-version: 1.0
|
||||
Content-Type: text/html; charset="UTF-8"
|
||||
From: "Fusen Support"
|
||||
|
@ -9,13 +9,13 @@ From: "Fusen Support"
|
|||
|
||||
<p>Dear <span style="color: red;">{{.UserName}}</span>,</p>
|
||||
|
||||
<p>Thank you for choosing {{ .CompanyName }}. To complete the account setup process, please click the button below to confirm your email address:</p>
|
||||
<p>Thank you for choosing to associate your email address with your {{ .CompanyName }} account({{ .PlatformAndID }}) . To complete the process, please click the button below to confirm your email:</p>
|
||||
|
||||
<a href="{{ .ConfirmationLink }}" target="_blank" style="background-color: #008CBA; color: #FFFFFF; text-decoration: none; padding: 10px 15px; border-radius: 3px; display:inline-block; font-weight: bold;">Confirm Email: {{ .Email }}</a>
|
||||
|
||||
<p>Confirming your email ensures your account is properly secured. This also allows you to access member-only tools and content.</p>
|
||||
<p>By confirming your email, you will be able to access additional features and receive important notifications related to your {{ .CompanyName }} account.</p>
|
||||
|
||||
<p>If you did not initiate this request or have any questions, please disregard this email. Your account will not be activated.</p>
|
||||
<p>If you did not initiate this request or have any questions, please disregard this email. Your email address will not be associated with any account.</p>
|
||||
|
||||
Regards,
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
// fs_admin_department 后台--部门表
|
||||
type FsAdminDepartment struct {
|
||||
Id int64 `gorm:"primary_key;default:0;" json:"id"` // 序号
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // 序号
|
||||
DeptPid *int64 `gorm:"default:0;" json:"dept_pid"` // 上级部门
|
||||
DeptNo *string `gorm:"default:'';" json:"dept_no"` //
|
||||
DeptName *string `gorm:"default:'';" json:"dept_name"` //
|
||||
|
|
|
@ -22,6 +22,7 @@ type FsAdminMenu struct {
|
|||
UpdateUid *int64 `gorm:"default:0;" json:"update_uid"` // 更新人
|
||||
DeleteUid *int64 `gorm:"default:0;" json:"delete_uid"` // 删除人
|
||||
IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除:1=是 0=否
|
||||
Status *int64 `gorm:"default:2;" json:"status"` // 状态:1=启用,2=停用
|
||||
}
|
||||
type FsAdminMenuModel struct {
|
||||
db *gorm.DB
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
// fs_admin_role 后台--角色表
|
||||
type FsAdminRole struct {
|
||||
Id int64 `gorm:"primary_key;default:0;" json:"id"` // 序号
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // 序号
|
||||
RolePid *int64 `gorm:"default:0;" json:"role_pid"` // 上级角色
|
||||
RoleName *string `gorm:"default:'';" json:"role_name"` //
|
||||
DataAuthType *int64 `gorm:"default:1;" json:"data_auth_type"` // 数据权限类型
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
// fs_admin_user 后台--管理员表
|
||||
type FsAdminUser struct {
|
||||
Id int64 `gorm:"primary_key;default:0;" json:"id"` // 序号
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // 序号
|
||||
DepartmentId *int64 `gorm:"default:0;" json:"department_id"` // 部门
|
||||
RoleId *int64 `gorm:"default:0;" json:"role_id"` // 角色
|
||||
EmployeeId *int64 `gorm:"default:0;" json:"employee_id"` // 员工
|
||||
|
|
|
@ -7,14 +7,13 @@ import (
|
|||
// fs_user 用户表
|
||||
type FsUser struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
||||
FaceId *int64 `gorm:"default:0;" json:"face_id"` // facebook的userid
|
||||
GoogleId *int64 `gorm:"default:0;" json:"google_id"` // google的sub
|
||||
FaceId *string `gorm:"default:'0';" json:"face_id"` // facebook的userid
|
||||
GoogleId *string `gorm:"default:'0';" json:"google_id"` // google的sub
|
||||
FirstName *string `gorm:"default:'';" json:"first_name"` // FirstName
|
||||
LastName *string `gorm:"default:'';" json:"last_name"` // LastName
|
||||
Username *string `gorm:"index;default:'';" json:"username"` //
|
||||
Company *string `gorm:"default:'';" json:"company"` // 公司名称
|
||||
Mobile *string `gorm:"default:'';" json:"mobile"` // 手机号码
|
||||
AuthKey *string `gorm:"default:'';" json:"auth_key"` //
|
||||
PasswordHash *string `gorm:"default:'';" json:"password_hash"` //
|
||||
VerificationToken *string `gorm:"default:'';" json:"verification_token"` //
|
||||
PasswordResetToken *string `gorm:"default:'';" json:"password_reset_token"` //
|
||||
|
|
|
@ -40,11 +40,16 @@ func (u *FsUserModel) FindUserById(ctx context.Context, Id int64) (resp FsUser,
|
|||
return resp, err
|
||||
}
|
||||
|
||||
func (u *FsUserModel) FindUserByGoogleId(ctx context.Context, Id int64) (resp FsUser, err error) {
|
||||
func (u *FsUserModel) FindUserByGoogleId(ctx context.Context, Id string) (resp FsUser, err error) {
|
||||
err = u.db.WithContext(ctx).Model(&FsUser{}).Where("`google_id` = ? and is_del = ?", Id, 0).Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (u *FsUserModel) FindUserByFacebookId(ctx context.Context, Id string) (resp FsUser, err error) {
|
||||
err = u.db.WithContext(ctx).Model(&FsUser{}).Where("`facebook_id` = ? and is_del = ?", Id, 0).Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (u *FsUserModel) Transaction(ctx context.Context, fc func(tx *gorm.DB) error) (err error) {
|
||||
return u.db.Model(&FsUser{}).WithContext(ctx).Transaction(fc)
|
||||
}
|
||||
|
@ -100,7 +105,7 @@ func (u *FsUserModel) RegisterByGoogleOAuth(ctx context.Context, token *auth.Reg
|
|||
user := &FsUser{}
|
||||
|
||||
err := u.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||
googleId := token.Extend["google_id"].(int64)
|
||||
googleId := token.Extend["oauth_id"].(string)
|
||||
firstName := token.Extend["first_name"].(string)
|
||||
lastName := token.Extend["last_name"].(string)
|
||||
|
||||
|
|
|
@ -76,10 +76,16 @@ func (l *UserEmailRegisterLogic) UserEmailRegister(req *types.RequestEmailRegist
|
|||
if token.Platform == auth.PLATFORM_FUSEN {
|
||||
tplsel = "email_register.tpl"
|
||||
} else {
|
||||
|
||||
tplsel = "email_register_oauth2.tpl"
|
||||
}
|
||||
|
||||
userName := token.Extend["first_name"].(string) + " " + token.Extend["last_name"].(string)
|
||||
var platformAndId string
|
||||
if oauthId, ok := token.Extend["oauth_id"]; ok {
|
||||
platformAndId = token.Platform + " Id: " + oauthId.(string)
|
||||
}
|
||||
|
||||
// 进入发送邮箱的系统
|
||||
EmailManager.EmailTasks <- &EmailFormat{
|
||||
TemplateName: tplsel,
|
||||
|
@ -90,8 +96,9 @@ func (l *UserEmailRegisterLogic) UserEmailRegister(req *types.RequestEmailRegist
|
|||
SenderName: "support@fusenpack.com",
|
||||
SenderTitle: "register-valid",
|
||||
Extend: map[string]string{
|
||||
"UserName": userName,
|
||||
"Email": req.Email,
|
||||
"UserName": userName,
|
||||
"Email": req.Email,
|
||||
"PlatformAndID": platformAndId,
|
||||
},
|
||||
} // email进入队
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ type UserGoogleLoginLogic struct {
|
|||
|
||||
isRegistered bool // 是否注册
|
||||
registerToken string // 注册邮箱的token
|
||||
defaultEmail string // 能从第三方拿到的默认邮箱
|
||||
registerInfo *auth.RegisterToken
|
||||
}
|
||||
|
||||
|
@ -75,7 +76,7 @@ func (l *UserGoogleLoginLogic) UserGoogleLogin(req *types.RequestGoogleLogin, us
|
|||
gresult := r.Json()
|
||||
logx.Info(gresult)
|
||||
|
||||
googleId := gresult.Get("id").Int()
|
||||
googleId := gresult.Get("id").String()
|
||||
user, err := l.svcCtx.AllModels.FsUser.FindUserByGoogleId(context.TODO(), googleId)
|
||||
if err != nil {
|
||||
if err != gorm.ErrRecordNotFound {
|
||||
|
@ -96,7 +97,7 @@ func (l *UserGoogleLoginLogic) UserGoogleLogin(req *types.RequestGoogleLogin, us
|
|||
TraceId: uuid.NewString(),
|
||||
CreateAt: time.Now().UTC(),
|
||||
Extend: map[string]interface{}{
|
||||
"google_id": googleId,
|
||||
"oauth_id": googleId,
|
||||
"first_name": gresult.Get("family_name").String(),
|
||||
"last_name": gresult.Get("given_name").String(),
|
||||
},
|
||||
|
@ -109,6 +110,7 @@ func (l *UserGoogleLoginLogic) UserGoogleLogin(req *types.RequestGoogleLogin, us
|
|||
return resp.SetStatus(basic.CodeOAuthRegisterTokenErr)
|
||||
}
|
||||
l.registerToken = token
|
||||
l.defaultEmail = gresult.Get("email").String()
|
||||
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
}
|
||||
|
@ -136,10 +138,11 @@ func (l *UserGoogleLoginLogic) AfterLogic(w http.ResponseWriter, r *http.Request
|
|||
logx.Info(l)
|
||||
|
||||
rurl := fmt.Sprintf(
|
||||
"http://www.fusen.3718.cn"+"/oauth?token=%s&is_registered=%t®ister_token=%s",
|
||||
"http://www.fusen.3718.cn"+"/oauth?token=%s&is_registered=%t®ister_token=%s&defaultEmail=%s",
|
||||
l.token,
|
||||
l.isRegistered,
|
||||
l.registerToken,
|
||||
l.registerInfo.Email,
|
||||
)
|
||||
|
||||
html := fmt.Sprintf(`
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"fusenapi/utils/file"
|
||||
"fusenapi/utils/hash"
|
||||
"image"
|
||||
"image/jpeg"
|
||||
"image/png"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
|
@ -91,7 +91,7 @@ func (l *LogoResizeLogic) LogoResize(req *types.LogoResizeReq, userinfo *auth.Us
|
|||
}
|
||||
|
||||
emptyBuff := bytes.NewBuffer(nil) //开辟一个新的空buff
|
||||
jpeg.Encode(emptyBuff, src, nil) //img写入到buff
|
||||
png.Encode(emptyBuff, src) //img写入到buff
|
||||
|
||||
var hashKeyDataMap = make(map[string]interface{})
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user