New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add multiple phonePrefix #1524
Conversation
…to phoneprefix � Conflicts: � object/organization.go � web/src/OrganizationEditPage.js � web/src/auth/SignupPage.js
@seriouszyx @ComradeProgrammer @Resulte please review |
@@ -296,6 +296,29 @@ func MigratePermissionRule() { | |||
} | |||
} | |||
|
|||
func MigratePhonePrefix() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a new file named migrate is better.
@@ -142,7 +143,11 @@ func (c *ApiController) SendVerificationCode() { | |||
return | |||
} | |||
|
|||
dest = fmt.Sprintf("+%s%s", organization.PhonePrefix, dest) | |||
if (phonePrefix == "" || phonePrefix == "undefined") && userByPhone != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle undefine in frontend. Just has "" condition in backend.
@@ -177,6 +178,7 @@ type Userinfo struct { | |||
Avatar string `json:"picture,omitempty"` | |||
Address string `json:"address,omitempty"` | |||
Phone string `json:"phone,omitempty"` | |||
PhonePrefix string `json:"phonePrefix,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not need. The Userinfo
struct is for oidc protocol.
phonePrefix = organization.PhonePrefix | ||
} | ||
checkDest = fmt.Sprintf("+%s%s", phonePrefix, dest) | ||
checkDest = fmt.Sprintf("%s%s", phonePrefix, dest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can phonePrefix
be empty?
@@ -177,7 +184,7 @@ func (c *ApiController) ResetEmailOrPhone() { | |||
checkDest := dest | |||
organization := object.GetOrganizationByUser(user) | |||
if destType == "phone" { | |||
if object.HasUserByField(user.Owner, "phone", user.Phone) { | |||
if object.HasUserByField(user.Owner, "phone", dest) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change it?
@@ -240,6 +240,7 @@ func (c *ApiController) Login() { | |||
var user *object.User | |||
var msg string | |||
|
|||
// Login with code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this
@@ -137,7 +137,7 @@ func (c *ApiController) Signup() { | |||
|
|||
var checkPhone string | |||
if application.IsSignupItemVisible("Phone") && form.Phone != "" { | |||
checkPhone = fmt.Sprintf("+%s%s", form.PhonePrefix, form.Phone) | |||
checkPhone = fmt.Sprintf("%s%s", form.PhonePrefix, form.Phone) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove + ?
@@ -257,16 +258,13 @@ func (c *ApiController) Login() { | |||
} | |||
checkDest = form.Username | |||
} else { | |||
verificationCodeType = "phone" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this?
@@ -97,7 +101,7 @@ export const ResetModal = (props) => { | |||
textBefore={i18next.t("code:Code You Received")} | |||
onChange={setCode} | |||
method={"reset"} | |||
onButtonClickArgs={[dest, destType, Setting.getApplicationName(application)]} | |||
onButtonClickArgs={[dest, destType, Setting.getApplicationName(application), null, phonePrefix]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's null?
if (isOrgnazition) { | ||
phoneArray = Setting.CountryPrefiexphone; | ||
} else { | ||
for (let i = 0; i < this.props.obj.phonePrefix.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
foreach
|
||
render() { | ||
const isOrgnazition = this.props.isOrgnazition; | ||
const wid = isOrgnazition ? "100%" : 100; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wid?
@@ -204,7 +207,7 @@ export const OtherProviderInfo = { | |||
}, | |||
}; | |||
|
|||
export function getCountryRegionData() { | |||
export function getCountryRegionData(key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't mess with getCountryRegionData
@@ -189,7 +189,7 @@ class LoginPage extends React.Component { | |||
} else { | |||
values["type"] = this.state.type; | |||
} | |||
values["phonePrefix"] = this.getApplicationObj()?.organizationObj.phonePrefix; | |||
// values["phonePrefix"] = this.getApplicationObj()?.organizationObj.phonePrefix[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just remove
Replaced by: #1557 |
Fix: #1397