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 {
columns = []string{
"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",
"signin_wrong_times", "last_signin_wrong_time",
}

View File

@ -184,7 +184,7 @@ class OrganizationEditPage extends React.Component {
</Row>
<Row style={{marginTop: "20px"}} >
<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 span={22} >
<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 [dest, setDest] = React.useState("");
const [code, setCode] = React.useState("");
const {buttonText, destType, application} = props;
const {buttonText, destType, application, account} = props;
const showModal = () => {
setVisible(true);
@ -87,7 +87,7 @@ export const ResetModal = (props) => {
<Row style={{width: "100%", marginBottom: "20px"}}>
<Input
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}
onChange={e => setDest(e.target.value)}
/>

View File

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

View File

@ -296,7 +296,7 @@ class UserEditPage extends React.Component {
</Col>
<Col span={Setting.isMobile() ? 22 : 11} >
{/* 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>
</Row>
);
@ -310,7 +310,7 @@ class UserEditPage extends React.Component {
<Input.Group compact style={{width: "280Px"}}>
<PhoneNumberInput
style={{width: "30%"}}
disabled={!Setting.isLocalAdminUser(this.props.account) ? true : disabled}
// disabled={!Setting.isLocalAdminUser(this.props.account) ? true : disabled}
value={this.state.user.countryCode}
onChange={(value) => {
this.updateUserField("countryCode", value);
@ -326,7 +326,7 @@ class UserEditPage extends React.Component {
</Input.Group>
</Col>
<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>
</Row>
);

View File

@ -251,8 +251,8 @@
"Successfully added": "Successfully added",
"Successfully deleted": "Successfully deleted",
"Successfully saved": "Successfully saved",
"Supported country code": "Supported country code",
"Supported country code - Tooltip": "Supported country code - Tooltip",
"Supported country codes": "Supported country codes",
"Supported country codes - Tooltip": "Supported country codes - Tooltip",
"Swagger": "Swagger",
"Sync": "Sync",
"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 code",
"Supported country code - Tooltip": "Supported country code - Tooltip",
"Supported country codes": "Supported country codes",
"Supported country codes - Tooltip": "Supported country codes - Tooltip",
"Swagger": "Swagger",
"Sync": "Sync",
"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 code",
"Supported country code - Tooltip": "Supported country code - Tooltip",
"Supported country codes": "Supported country codes",
"Supported country codes - Tooltip": "Supported country codes - Tooltip",
"Swagger": "Swagger",
"Sync": "Sincronizador",
"Syncers": "Sincronizadores",

View File

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

View File

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

View File

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

View File

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