Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e09a1a9

Browse files
committed
注册不用验证邮箱时,直接登录
1 parent 0b53040 commit e09a1a9

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/http/controller/account.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,29 @@ func (self AccountController) Register(ctx echo.Context) error {
110110
pos := strings.LastIndex(email, "@")
111111
emailUrl = "http://mail." + email[pos+1:]
112112
}
113-
data = map[string]interface{}{
114-
"success": template.HTML(`
115-
<div style="padding:30px 30px 50px 30px;">
116-
<div style="color:#339502;font-size:22px;line-height: 2.5;">恭喜您注册成功!</div>
117-
我们已经发送一封邮件到 ` + email + `,请您根据提示信息完成邮箱验证.<br><br>
118-
<a href="` + emailUrl + `" target="_blank"><button type="button" class="btn btn-success">立即验证</button></a>&nbsp;&nbsp;<button type="button" class="btn btn-link" data-uuid="` + uuid + `" id="resend_email">未收到?再发一次</button>
119-
</div>`),
120-
}
121113

122114
if config.ConfigFile.MustBool("account", "verify_email", true) {
115+
data = map[string]interface{}{
116+
"success": template.HTML(`
117+
<div style="padding:30px 30px 50px 30px;">
118+
<div style="color:#339502;font-size:22px;line-height: 2.5;">恭喜您注册成功!</div>
119+
我们已经发送一封邮件到 ` + email + `,请您根据提示信息完成邮箱验证.<br><br>
120+
<a href="` + emailUrl + `" target="_blank"><button type="button" class="btn btn-success">立即验证</button></a>&nbsp;&nbsp;<button type="button" class="btn btn-link" data-uuid="` + uuid + `" id="resend_email">未收到?再发一次</button>
121+
</div>`),
122+
}
123+
123124
isHttps := goutils.MustBool(ctx.Request().Header().Get("X-Https"))
124125
// 需要检验邮箱的正确性
125126
go logic.DefaultEmail.SendActivateMail(email, uuid, isHttps)
127+
128+
return render(ctx, registerTpl, data)
126129
}
127130

128-
return render(ctx, registerTpl, data)
131+
// 不验证邮箱,注册完成直接登录
132+
// 自动登录
133+
SetLoginCookie(ctx, username)
134+
135+
return ctx.Redirect(http.StatusSeeOther, "/balance")
129136
}
130137

131138
// SendActivateEmail 发送注册激活邮件

0 commit comments

Comments
 (0)