fix resetting phone bug

This commit is contained in:
Gucheng Wang 2023-02-25 15:46:54 +08:00
parent 181e7c8c7d
commit f5672357e6
14 changed files with 29 additions and 25 deletions

View File

@ -449,7 +449,7 @@ func UpdateUser(id string, user *User, columns []string, isGlobalAdmin bool) boo
if len(columns) == 0 { if len(columns) == 0 {
columns = []string{ columns = []string{
"owner", "display_name", "avatar", "owner", "display_name", "avatar",
"location", "address", "region", "language", "affiliation", "title", "homepage", "bio", "score", "tag", "signup_application", "location", "address", "country_code", "region", "language", "affiliation", "title", "homepage", "bio", "score", "tag", "signup_application",
"is_admin", "is_global_admin", "is_forbidden", "is_deleted", "hash", "is_default_avatar", "properties", "webauthnCredentials", "managedAccounts", "is_admin", "is_global_admin", "is_forbidden", "is_deleted", "hash", "is_default_avatar", "properties", "webauthnCredentials", "managedAccounts",
"signin_wrong_times", "last_signin_wrong_time", "signin_wrong_times", "last_signin_wrong_time",
} }

View File

@ -184,7 +184,7 @@ class OrganizationEditPage extends React.Component {
</Row> </Row>
<Row style={{marginTop: "20px"}} > <Row style={{marginTop: "20px"}} >
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}> <Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
{Setting.getLabel(i18next.t("general:Supported country code"), i18next.t("general:Supported country code - Tooltip"))} : {Setting.getLabel(i18next.t("general:Supported country codes"), i18next.t("general:Supported country codes - Tooltip"))} :
</Col> </Col>
<Col span={22} > <Col span={22} >
<Select virtual={false} mode={"multiple"} style={{width: "100%"}} value={this.state.organization.countryCodes ?? []} <Select virtual={false} mode={"multiple"} style={{width: "100%"}} value={this.state.organization.countryCodes ?? []}

View File

@ -25,7 +25,7 @@ export const ResetModal = (props) => {
const [confirmLoading, setConfirmLoading] = React.useState(false); const [confirmLoading, setConfirmLoading] = React.useState(false);
const [dest, setDest] = React.useState(""); const [dest, setDest] = React.useState("");
const [code, setCode] = React.useState(""); const [code, setCode] = React.useState("");
const {buttonText, destType, application} = props; const {buttonText, destType, application, account} = props;
const showModal = () => { const showModal = () => {
setVisible(true); setVisible(true);
@ -87,7 +87,7 @@ export const ResetModal = (props) => {
<Row style={{width: "100%", marginBottom: "20px"}}> <Row style={{width: "100%", marginBottom: "20px"}}>
<Input <Input
addonBefore={destType === "email" ? i18next.t("user:New Email") : i18next.t("user:New phone")} addonBefore={destType === "email" ? i18next.t("user:New Email") : i18next.t("user:New phone")}
prefix={destType === "email" ? <MailOutlined /> : <PhoneOutlined />} prefix={destType === "email" ? <React.Fragment><MailOutlined />&nbsp;&nbsp;</React.Fragment> : (<React.Fragment><PhoneOutlined />&nbsp;&nbsp;{`+${Setting.getCountryCode(account.countryCode)}`}&nbsp;</React.Fragment>)}
placeholder={placeholder} placeholder={placeholder}
onChange={e => setDest(e.target.value)} onChange={e => setDest(e.target.value)}
/> />

View File

@ -208,6 +208,10 @@ export function initCountries() {
return countries; return countries;
} }
export function getCountryCode(country) {
return phoneNumber.getCountryCallingCode(country);
}
export function getCountryCodeData(countryCodes = phoneNumber.getCountries()) { export function getCountryCodeData(countryCodes = phoneNumber.getCountries()) {
return countryCodes?.map((countryCode) => { return countryCodes?.map((countryCode) => {
if (phoneNumber.isSupportedCountry(countryCode)) { if (phoneNumber.isSupportedCountry(countryCode)) {

View File

@ -296,7 +296,7 @@ class UserEditPage extends React.Component {
</Col> </Col>
<Col span={Setting.isMobile() ? 22 : 11} > <Col span={Setting.isMobile() ? 22 : 11} >
{/* backend auto get the current user, so admin can not edit. Just self can reset*/} {/* backend auto get the current user, so admin can not edit. Just self can reset*/}
{this.isSelf() ? <ResetModal application={this.state.application} disabled={disabled} buttonText={i18next.t("user:Reset Email...")} destType={"email"} /> : null} {this.isSelf() ? <ResetModal application={this.state.application} account={this.props.account} disabled={disabled} buttonText={i18next.t("user:Reset Email...")} destType={"email"} /> : null}
</Col> </Col>
</Row> </Row>
); );
@ -310,7 +310,7 @@ class UserEditPage extends React.Component {
<Input.Group compact style={{width: "280Px"}}> <Input.Group compact style={{width: "280Px"}}>
<PhoneNumberInput <PhoneNumberInput
style={{width: "30%"}} style={{width: "30%"}}
disabled={!Setting.isLocalAdminUser(this.props.account) ? true : disabled} // disabled={!Setting.isLocalAdminUser(this.props.account) ? true : disabled}
value={this.state.user.countryCode} value={this.state.user.countryCode}
onChange={(value) => { onChange={(value) => {
this.updateUserField("countryCode", value); this.updateUserField("countryCode", value);
@ -326,7 +326,7 @@ class UserEditPage extends React.Component {
</Input.Group> </Input.Group>
</Col> </Col>
<Col span={Setting.isMobile() ? 24 : 11} > <Col span={Setting.isMobile() ? 24 : 11} >
{this.isSelf() ? (<ResetModal application={this.state.application} disabled={disabled} buttonText={i18next.t("user:Reset Phone...")} destType={"phone"} />) : null} {this.isSelf() ? (<ResetModal application={this.state.application} account={this.props.account} disabled={disabled} buttonText={i18next.t("user:Reset Phone...")} destType={"phone"} />) : null}
</Col> </Col>
</Row> </Row>
); );

View File

@ -251,8 +251,8 @@
"Successfully added": "Successfully added", "Successfully added": "Successfully added",
"Successfully deleted": "Successfully deleted", "Successfully deleted": "Successfully deleted",
"Successfully saved": "Successfully saved", "Successfully saved": "Successfully saved",
"Supported country code": "Supported country code", "Supported country codes": "Supported country codes",
"Supported country code - Tooltip": "Supported country code - Tooltip", "Supported country codes - Tooltip": "Supported country codes - Tooltip",
"Swagger": "Swagger", "Swagger": "Swagger",
"Sync": "Sync", "Sync": "Sync",
"Syncers": "Syncers", "Syncers": "Syncers",

View File

@ -251,8 +251,8 @@
"Successfully added": "Successfully added", "Successfully added": "Successfully added",
"Successfully deleted": "Successfully deleted", "Successfully deleted": "Successfully deleted",
"Successfully saved": "Successfully saved", "Successfully saved": "Successfully saved",
"Supported country code": "Supported country code", "Supported country codes": "Supported country codes",
"Supported country code - Tooltip": "Supported country code - Tooltip", "Supported country codes - Tooltip": "Supported country codes - Tooltip",
"Swagger": "Swagger", "Swagger": "Swagger",
"Sync": "Sync", "Sync": "Sync",
"Syncers": "Syncers", "Syncers": "Syncers",

View File

@ -251,8 +251,8 @@
"Successfully added": "Successfully added", "Successfully added": "Successfully added",
"Successfully deleted": "Successfully deleted", "Successfully deleted": "Successfully deleted",
"Successfully saved": "Successfully saved", "Successfully saved": "Successfully saved",
"Supported country code": "Supported country code", "Supported country codes": "Supported country codes",
"Supported country code - Tooltip": "Supported country code - Tooltip", "Supported country codes - Tooltip": "Supported country codes - Tooltip",
"Swagger": "Swagger", "Swagger": "Swagger",
"Sync": "Sincronizador", "Sync": "Sincronizador",
"Syncers": "Sincronizadores", "Syncers": "Sincronizadores",

View File

@ -251,8 +251,8 @@
"Successfully added": "Successfully added", "Successfully added": "Successfully added",
"Successfully deleted": "Successfully deleted", "Successfully deleted": "Successfully deleted",
"Successfully saved": "Successfully saved", "Successfully saved": "Successfully saved",
"Supported country code": "Supported country code", "Supported country codes": "Supported country codes",
"Supported country code - Tooltip": "Supported country code - Tooltip", "Supported country codes - Tooltip": "Supported country codes - Tooltip",
"Swagger": "Swagger", "Swagger": "Swagger",
"Sync": "Sync", "Sync": "Sync",
"Syncers": "Synchronisateurs", "Syncers": "Synchronisateurs",

View File

@ -251,8 +251,8 @@
"Successfully added": "Successfully added", "Successfully added": "Successfully added",
"Successfully deleted": "Successfully deleted", "Successfully deleted": "Successfully deleted",
"Successfully saved": "Successfully saved", "Successfully saved": "Successfully saved",
"Supported country code": "Supported country code", "Supported country codes": "Supported country codes",
"Supported country code - Tooltip": "Supported country code - Tooltip", "Supported country codes - Tooltip": "Supported country codes - Tooltip",
"Swagger": "Swagger", "Swagger": "Swagger",
"Sync": "Sync", "Sync": "Sync",
"Syncers": "Syncers", "Syncers": "Syncers",

View File

@ -251,8 +251,8 @@
"Successfully added": "Successfully added", "Successfully added": "Successfully added",
"Successfully deleted": "Successfully deleted", "Successfully deleted": "Successfully deleted",
"Successfully saved": "Successfully saved", "Successfully saved": "Successfully saved",
"Supported country code": "Supported country code", "Supported country codes": "Supported country codes",
"Supported country code - Tooltip": "Supported country code - Tooltip", "Supported country codes - Tooltip": "Supported country codes - Tooltip",
"Swagger": "Swagger", "Swagger": "Swagger",
"Sync": "Sync", "Sync": "Sync",
"Syncers": "Syncers", "Syncers": "Syncers",

View File

@ -251,8 +251,8 @@
"Successfully added": "Successfully added", "Successfully added": "Successfully added",
"Successfully deleted": "Successfully deleted", "Successfully deleted": "Successfully deleted",
"Successfully saved": "Successfully saved", "Successfully saved": "Successfully saved",
"Supported country code": "Supported country code", "Supported country codes": "Supported country codes",
"Supported country code - Tooltip": "Supported country code - Tooltip", "Supported country codes - Tooltip": "Supported country codes - Tooltip",
"Swagger": "Swagger", "Swagger": "Swagger",
"Sync": "Sync", "Sync": "Sync",
"Syncers": "Синхронизаторы", "Syncers": "Синхронизаторы",

View File

@ -251,8 +251,8 @@
"Successfully added": "Successfully added", "Successfully added": "Successfully added",
"Successfully deleted": "Successfully deleted", "Successfully deleted": "Successfully deleted",
"Successfully saved": "Successfully saved", "Successfully saved": "Successfully saved",
"Supported country code": "Supported country code", "Supported country codes": "Supported country codes",
"Supported country code - Tooltip": "Supported country code - Tooltip", "Supported country codes - Tooltip": "Supported country codes - Tooltip",
"Swagger": "Swagger", "Swagger": "Swagger",
"Sync": "Sync", "Sync": "Sync",
"Syncers": "Syncers", "Syncers": "Syncers",

View File

@ -251,8 +251,8 @@
"Successfully added": "添加成功", "Successfully added": "添加成功",
"Successfully deleted": "删除成功", "Successfully deleted": "删除成功",
"Successfully saved": "保存成功", "Successfully saved": "保存成功",
"Supported country code": "支持的国家代码", "Supported country codes": "支持的国家代码",
"Supported country code - Tooltip": "支持发送短信的国家 - Tooltip", "Supported country codes - Tooltip": "支持发送短信的国家 - Tooltip",
"Swagger": "API文档", "Swagger": "API文档",
"Sync": "同步", "Sync": "同步",
"Syncers": "同步器", "Syncers": "同步器",