mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 12:30:19 +08:00
fix: check cn phone regex bug and add check to verification code
Signed-off-by: Kininaru <shiftregister233@outlook.com>
This commit is contained in:
@ -19,6 +19,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/casdoor/casdoor/object"
|
||||
"github.com/casdoor/casdoor/util"
|
||||
)
|
||||
|
||||
func (c *ApiController) SendVerificationCode() {
|
||||
@ -47,8 +48,16 @@ func (c *ApiController) SendVerificationCode() {
|
||||
ret := "Invalid dest type."
|
||||
switch destType {
|
||||
case "email":
|
||||
if !util.IsEmailValid(dest) {
|
||||
c.ResponseError("Invalid Email address")
|
||||
return
|
||||
}
|
||||
ret = object.SendVerificationCodeToEmail(remoteAddr, dest)
|
||||
case "phone":
|
||||
if !util.IsPhoneCnValid(dest) {
|
||||
c.ResponseError("Invalid phone number")
|
||||
return
|
||||
}
|
||||
org := object.GetOrganizationByName(user.Owner)
|
||||
phonePrefix := "86"
|
||||
if org != nil && org.PhonePrefix != "" {
|
||||
|
Reference in New Issue
Block a user