mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-24 08:20:31 +08:00
Improve "Third-party logins" UI.
This commit is contained in:
parent
95cda41732
commit
90e617b2dc
@ -112,9 +112,9 @@ class UserEditPage extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
getProviderLink(provider, linkedValue) {
|
||||
getProviderLink(provider) {
|
||||
if (provider.type === "GitHub") {
|
||||
return `https://github.com/${linkedValue}`;
|
||||
return `https://github.com/${this.getUserProperty(provider.type, "username")}`;
|
||||
} else if (provider.type === "Google") {
|
||||
return "https://mail.google.com";
|
||||
} else {
|
||||
@ -122,8 +122,19 @@ class UserEditPage extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
getUserProperty(providerType, propertyName) {
|
||||
const key = `oauth_${providerType}_${propertyName}`;
|
||||
return this.state.user.properties[key]
|
||||
}
|
||||
|
||||
renderIdp(provider) {
|
||||
const linkedValue = this.state.user[provider.type.toLowerCase()];
|
||||
const profileUrl = this.getProviderLink(provider);
|
||||
const username = this.getUserProperty(provider.type, "username");
|
||||
const displayName = this.getUserProperty(provider.type, "displayname");
|
||||
// const email = this.getUserProperty(provider.type, "email");
|
||||
const avatarUrl = this.getUserProperty(provider.type, "avatarUrl");
|
||||
const name = (username === undefined) ? displayName : `${displayName} (${username})`;
|
||||
|
||||
return (
|
||||
<Row key={provider.name} style={{marginTop: '20px'}} >
|
||||
@ -138,17 +149,20 @@ class UserEditPage extends React.Component {
|
||||
</span>
|
||||
</Col>
|
||||
<Col span={22} >
|
||||
<span style={{width: '200px', display: "inline-block"}}>
|
||||
<img style={{marginRight: '10px'}} width={30} height={30} src={avatarUrl} alt={name} />
|
||||
<span style={{width: '300px', display: "inline-block"}}>
|
||||
{
|
||||
linkedValue === "" ? (
|
||||
"(empty)"
|
||||
) : (
|
||||
<a target="_blank" rel="noreferrer" href={this.getProviderLink(provider, linkedValue)}>
|
||||
profileUrl === "" ? name : (
|
||||
<a target="_blank" rel="noreferrer" href={profileUrl}>
|
||||
{
|
||||
linkedValue
|
||||
name
|
||||
}
|
||||
</a>
|
||||
)
|
||||
)
|
||||
}
|
||||
</span>
|
||||
{
|
||||
@ -165,6 +179,10 @@ class UserEditPage extends React.Component {
|
||||
)
|
||||
}
|
||||
|
||||
isSelfOrAdmin() {
|
||||
return (this.state.user.id === this.props.account?.id) || Setting.isAdminUser(this.props.account);
|
||||
}
|
||||
|
||||
renderUser() {
|
||||
return (
|
||||
<Card size="small" title={
|
||||
@ -272,7 +290,7 @@ class UserEditPage extends React.Component {
|
||||
<Input value={this.state.user.email} disabled />
|
||||
</Col>
|
||||
<Col span={11} >
|
||||
{ this.state.user.id === this.props.account.id ? (<ResetModal org={this.state.application?.organizationObj} buttonText={i18next.t("user:Reset Email...")} destType={"email"} coolDownTime={60}/>) : null}
|
||||
{ this.state.user.id === this.props.account?.id ? (<ResetModal org={this.state.application?.organizationObj} buttonText={i18next.t("user:Reset Email...")} destType={"email"} coolDownTime={60}/>) : null}
|
||||
</Col>
|
||||
</Row>
|
||||
<Row style={{marginTop: '20px'}} >
|
||||
@ -283,7 +301,7 @@ class UserEditPage extends React.Component {
|
||||
<Input value={this.state.user.phone} addonBefore={`+${this.state.application?.organizationObj.phonePrefix}`} disabled />
|
||||
</Col>
|
||||
<Col span={11} >
|
||||
{ this.state.user.id === this.props.account.id ? (<ResetModal org={this.state.application?.organizationObj} buttonText={i18next.t("user:Reset Phone...")} destType={"phone"} coolDownTime={60}/>) : null}
|
||||
{ this.state.user.id === this.props.account?.id ? (<ResetModal org={this.state.application?.organizationObj} buttonText={i18next.t("user:Reset Phone...")} destType={"phone"} coolDownTime={60}/>) : null}
|
||||
</Col>
|
||||
</Row>
|
||||
<Row style={{marginTop: '20px'}} >
|
||||
@ -314,6 +332,8 @@ class UserEditPage extends React.Component {
|
||||
}} />
|
||||
</Col>
|
||||
</Row>
|
||||
{
|
||||
!this.isSelfOrAdmin() ? null : (
|
||||
<Row style={{marginTop: '20px'}} >
|
||||
<Col style={{marginTop: '5px'}} span={2}>
|
||||
{i18next.t("user:Third-party logins")}:
|
||||
@ -326,24 +346,22 @@ class UserEditPage extends React.Component {
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
{
|
||||
!Setting.isAdminUser(this.props.account) ? null : (
|
||||
<Row style={{marginTop: '20px'}} >
|
||||
<Col style={{marginTop: '5px'}} span={2}>
|
||||
{i18next.t("user:Properties")}:
|
||||
</Col>
|
||||
<Col span={22} >
|
||||
<CodeMirror
|
||||
value={JSON.stringify(this.state.user.properties, null, 4)}
|
||||
options={{mode: 'javascript', theme: "material-darker"}}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
)
|
||||
}
|
||||
{
|
||||
!Setting.isAdminUser(this.props.account) ? null : (
|
||||
<React.Fragment>
|
||||
{/*<Row style={{marginTop: '20px'}} >*/}
|
||||
{/* <Col style={{marginTop: '5px'}} span={2}>*/}
|
||||
{/* {i18next.t("user:Properties")}:*/}
|
||||
{/* </Col>*/}
|
||||
{/* <Col span={22} >*/}
|
||||
{/* <CodeMirror*/}
|
||||
{/* value={JSON.stringify(this.state.user.properties, null, 4)}*/}
|
||||
{/* options={{mode: 'javascript', theme: "material-darker"}}*/}
|
||||
{/* />*/}
|
||||
{/* </Col>*/}
|
||||
{/*</Row>*/}
|
||||
<Row style={{marginTop: '20px'}} >
|
||||
<Col style={{marginTop: '5px'}} span={2}>
|
||||
{i18next.t("user:Is admin")}:
|
||||
|
Loading…
x
Reference in New Issue
Block a user