Merge pull request #804 from Go-Go-Farther/bugfix

bugfix: 
1. 修改账号正则,允许全数字账号,保证能通过已有全数字账号体系登录;
2. Prepare函数重复执行。
pull/806/head
玖亖伍 2022-07-14 10:22:36 +08:00 committed by GitHub
commit 83bca4ac40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 14 deletions

View File

@ -20,7 +20,7 @@ const CaptchaSessionName = "__captcha__"
const RegexpEmail = "^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$" const RegexpEmail = "^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"
//允许用户名中出现点号 //允许用户名中出现点号
const RegexpAccount = `^[a-zA-Z][a-zA-Z0-9\.-]{2,50}$` const RegexpAccount = `^[a-zA-Z0-9][a-zA-Z0-9\.-]{2,50}$`
// PageSize 默认分页条数. // PageSize 默认分页条数.
const PageSize = 10 const PageSize = 10

View File

@ -99,8 +99,6 @@ func (c *AccountController) Prepare() {
// Login 用户登录 // Login 用户登录
func (c *AccountController) Login() { func (c *AccountController) Login() {
c.Prepare()
c.TplName = "account/login.tpl" c.TplName = "account/login.tpl"
if member, ok := c.GetSession(conf.LoginSessionName).(models.Member); ok && member.MemberId > 0 { if member, ok := c.GetSession(conf.LoginSessionName).(models.Member); ok && member.MemberId > 0 {
@ -205,8 +203,6 @@ func (c *AccountController) Login() {
// 钉钉登录 // 钉钉登录
func (c *AccountController) DingTalkLogin() { func (c *AccountController) DingTalkLogin() {
c.Prepare()
code := c.GetString("dingtalk_code") code := c.GetString("dingtalk_code")
if code == "" { if code == "" {
c.JsonResult(500, i18n.Tr(c.Lang, "message.failed_obtain_user_info"), nil) c.JsonResult(500, i18n.Tr(c.Lang, "message.failed_obtain_user_info"), nil)
@ -259,8 +255,6 @@ func (c *AccountController) DingTalkLogin() {
// WorkWeixinLogin 用户企业微信登录 // WorkWeixinLogin 用户企业微信登录
func (c *AccountController) WorkWeixinLogin() { func (c *AccountController) WorkWeixinLogin() {
c.Prepare()
logs.Info("UserAgent: ", c.Ctx.Input.UserAgent()) // debug logs.Info("UserAgent: ", c.Ctx.Input.UserAgent()) // debug
if member, ok := c.GetSession(conf.LoginSessionName).(models.Member); ok && member.MemberId > 0 { if member, ok := c.GetSession(conf.LoginSessionName).(models.Member); ok && member.MemberId > 0 {
@ -508,8 +502,6 @@ func (c *AccountController) WorkWeixinLoginCallback() {
// WorkWeixinLoginBind 用户企业微信登录-绑定 // WorkWeixinLoginBind 用户企业微信登录-绑定
func (c *AccountController) WorkWeixinLoginBind() { func (c *AccountController) WorkWeixinLoginBind() {
c.Prepare()
if user_info, ok := c.GetSession(SessionUserInfoKey).(workweixin.WorkWeixinUserInfo); ok && len(user_info.UserId) > 0 { if user_info, ok := c.GetSession(SessionUserInfoKey).(workweixin.WorkWeixinUserInfo); ok && len(user_info.UserId) > 0 {
req_account := c.GetString("account") req_account := c.GetString("account")
req_password := c.GetString("password") req_password := c.GetString("password")
@ -670,8 +662,6 @@ func (c *AccountController) WorkWeixinLoginIgnore() {
// QR二维码登录 // QR二维码登录
func (c *AccountController) QRLogin() { func (c *AccountController) QRLogin() {
c.Prepare()
appName := c.Ctx.Input.Param(":app") appName := c.Ctx.Input.Param(":app")
switch appName { switch appName {
@ -969,7 +959,6 @@ func (c *AccountController) FindPassword() {
// 校验邮件并修改密码 // 校验邮件并修改密码
func (c *AccountController) ValidEmail() { func (c *AccountController) ValidEmail() {
c.Prepare()
password1 := c.GetString("password1") password1 := c.GetString("password1")
password2 := c.GetString("password2") password2 := c.GetString("password2")
captcha := c.GetString("code") captcha := c.GetString("code")
@ -1043,8 +1032,6 @@ func (c *AccountController) Logout() {
// 验证码 // 验证码
func (c *AccountController) Captcha() { func (c *AccountController) Captcha() {
c.Prepare()
captchaImage := gocaptcha.NewCaptchaImage(140, 40, gocaptcha.RandLightColor()) captchaImage := gocaptcha.NewCaptchaImage(140, 40, gocaptcha.RandLightColor())
captchaImage.DrawNoise(gocaptcha.CaptchaComplexLower) captchaImage.DrawNoise(gocaptcha.CaptchaComplexLower)