Browse Source

代码提交。

Signed-off-by: zouap <zouap@pcl.ac.cn>
pull/2977/head
zouap 2 years ago
parent
commit
4c967682be
1 changed files with 16 additions and 10 deletions
  1. +16
    -10
      routers/user/Invitation.go

+ 16
- 10
routers/user/Invitation.go View File

@@ -5,7 +5,6 @@ import (
"strings"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/auth"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/log"
@@ -55,23 +54,30 @@ func InviationTpl(ctx *context.Context) {
ctx.HTML(200, tplInvitation)
}

func RegisteUserByInvitaionCode(form auth.RegisterForm, newUserId int64) error {
invitationcode := form.InvitaionCode
func RegisteUserByInvitaionCode(invitationcode string, newUserId int64) error {
user := parseInvitaionCode(invitationcode)
if user == nil {
return errors.New("The invitated user not existed.")
}

re := models.QueryInvitaionByPhone(form.PhoneNumber)
if re != nil {
if len(re) > 0 {
log.Info("The phone has been invitated. so ingore it.")
return errors.New("The phone has been invitated.")
if user.PhoneNumber != "" {
re := models.QueryInvitaionByPhone(user.PhoneNumber)
if re != nil {
if len(re) > 0 {
log.Info("The phone has been invitated. so ingore it.")
return errors.New("The phone has been invitated.")
}
}
} else {
log.Info("the phone number is null. user name=" + user.Name)
}

user := parseInvitaionCode(invitationcode)
invitation := &models.Invitation{
SrcUserID: user.ID,
UserID: newUserId,
Phone: form.PhoneNumber,
Phone: user.PhoneNumber,
}

err := models.InsertInvitaion(invitation)
if err != nil {
log.Info("insert error," + err.Error())


Loading…
Cancel
Save