Check user under org.

This commit is contained in:
Yang Luo
2021-02-14 21:21:42 +08:00
parent 7203dcbe22
commit 65eee22099
11 changed files with 64 additions and 38 deletions

View File

@ -273,7 +273,7 @@ class App extends Component {
</Header>
<Switch>
<Route exact path="/login" render={(props) => this.renderHomeIfLoggedIn(<LoginPage onLoggedIn={this.onLoggedIn.bind(this)} {...props} />)}/>
<Route exact path="/callback/:providerType/:providerName/:method" component={AuthCallback}/>
<Route exact path="/callback/:applicationName/:providerName/:method" component={AuthCallback}/>
<Route exact path="/" render={(props) => this.renderLoginIfNotLoggedIn(<HomePage account={this.state.account} onLoggedIn={this.onLoggedIn.bind(this)} {...props} />)}/>
<Route exact path="/account" render={(props) => this.renderLoginIfNotLoggedIn(<AccountPage account={this.state.account} {...props} />)}/>
<Route exact path="/organizations" render={(props) => this.renderLoginIfNotLoggedIn(<OrganizationListPage account={this.state.account} {...props} />)}/>

View File

@ -198,6 +198,24 @@ class UserEditPage extends React.Component {
}} />
</Col>
</Row>
<Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={2}>
Tag:
</Col>
<Col span={22} >
<Input value={this.state.user.tag} onChange={e => {
this.updateUserField('tag', e.target.value);
}} />
</Col>
</Row>
<Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={2}>
GitHub:
</Col>
<Col span={22} >
<Input value={this.state.user.github} disabled={true} />
</Col>
</Row>
<Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={2}>
Is Admin:

View File

@ -104,7 +104,7 @@ class UserListPage extends React.Component {
title: 'Name',
dataIndex: 'name',
key: 'name',
width: '120px',
width: '100px',
sorter: (a, b) => a.name.localeCompare(b.name),
render: (text, record, index) => {
return (
@ -124,13 +124,13 @@ class UserListPage extends React.Component {
return Setting.getFormattedDate(text);
}
},
{
title: 'Password Type',
dataIndex: 'passwordType',
key: 'passwordType',
width: '150px',
sorter: (a, b) => a.passwordType.localeCompare(b.passwordType),
},
// {
// title: 'Password Type',
// dataIndex: 'passwordType',
// key: 'passwordType',
// width: '150px',
// sorter: (a, b) => a.passwordType.localeCompare(b.passwordType),
// },
// {
// title: 'Password',
// dataIndex: 'password',
@ -162,7 +162,7 @@ class UserListPage extends React.Component {
title: 'Email',
dataIndex: 'email',
key: 'email',
width: '180px',
width: '160px',
sorter: (a, b) => a.email.localeCompare(b.email),
render: (text, record, index) => {
return (
@ -172,13 +172,13 @@ class UserListPage extends React.Component {
)
}
},
{
title: 'Phone',
dataIndex: 'phone',
key: 'phone',
width: '120px',
sorter: (a, b) => a.phone.localeCompare(b.phone),
},
// {
// title: 'Phone',
// dataIndex: 'phone',
// key: 'phone',
// width: '120px',
// sorter: (a, b) => a.phone.localeCompare(b.phone),
// },
{
title: 'Affiliation',
dataIndex: 'affiliation',
@ -186,6 +186,13 @@ class UserListPage extends React.Component {
width: '120px',
sorter: (a, b) => a.affiliation.localeCompare(b.affiliation),
},
{
title: 'Tag',
dataIndex: 'tag',
key: 'tag',
width: '100px',
sorter: (a, b) => a.tag.localeCompare(b.tag),
},
{
title: 'Is Admin',
dataIndex: 'isAdmin',

View File

@ -44,8 +44,8 @@ export function logout() {
}).then(res => res.json());
}
export function authLogin(providerName, code, state, redirectUrl, method) {
return fetch(`${authConfig.serverUrl}/api/auth/login?provider=${providerName}&code=${code}&state=${state}&redirect_url=${redirectUrl}&method=${method}`, {
export function authLogin(applicationName, providerName, code, state, redirectUrl, method) {
return fetch(`${authConfig.serverUrl}/api/auth/login?application=${applicationName}&provider=${providerName}&code=${code}&state=${state}&redirect_url=${redirectUrl}&method=${method}`, {
method: 'GET',
credentials: 'include',
}).then(res => res.json());

View File

@ -23,7 +23,7 @@ class AuthCallback extends React.Component {
const params = new URLSearchParams(this.props.location.search);
this.state = {
classes: props,
providerType: props.match.params.providerType,
applicationName: props.match.params.applicationName,
providerName: props.match.params.providerName,
method: props.match.params.method,
state: params.get("state"),
@ -48,8 +48,8 @@ class AuthCallback extends React.Component {
authLogin() {
let redirectUrl;
redirectUrl = `${window.location.origin}/callback/${this.state.providerType}/${this.state.providerName}/${this.state.method}`;
AuthBackend.authLogin(this.state.providerName, this.state.code, this.state.state, redirectUrl, this.state.method)
redirectUrl = `${window.location.origin}/callback/${this.state.applicationName}/${this.state.providerName}/${this.state.method}`;
AuthBackend.authLogin(this.state.applicationName, this.state.providerName, this.state.code, this.state.state, redirectUrl, this.state.method)
.then((res) => {
if (res.status === "ok") {
window.location.href = '/';

View File

@ -128,7 +128,7 @@ class Face extends React.Component {
{
this.getApplicationObj().providerObjs.map(provider => {
return (
<a href={Provider.getAuthUrl(provider, "signup")}>
<a href={Provider.getAuthUrl(this.getApplicationObj(), provider, "signup")}>
<img width={30} height={30} src={Provider.getAuthLogo(provider)} alt={provider.displayName} style={{margin: "3px"}} />
</a>
);

View File

@ -42,8 +42,8 @@ export function getAuthLogo(provider) {
}
}
export function getAuthUrl(provider, method) {
const redirectUri = `${window.location.origin}/callback/${provider.type}/${provider.name}/${method}`;
export function getAuthUrl(application, provider, method) {
const redirectUri = `${window.location.origin}/callback/${application.name}/${provider.name}/${method}`;
if (provider.type === "google") {
return `${GoogleAuthUri}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${GoogleAuthScope}&response_type=code&state=${AuthState}`;
} else if (provider.type === "github") {