Add organization and user to token.

This commit is contained in:
Yang Luo 2021-05-04 22:36:05 +08:00
parent 6095af0512
commit fffada894c
2 changed files with 49 additions and 17 deletions

View File

@ -31,7 +31,9 @@ type Token struct {
Name string `xorm:"varchar(100) notnull pk" json:"name"`
CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
Application string `xorm:"varchar(100)" json:"application"`
Application string `xorm:"varchar(100)" json:"application"`
Organization string `xorm:"varchar(100)" json:"organization"`
User string `xorm:"varchar(100)" json:"user"`
Code string `xorm:"varchar(100)" json:"code"`
AccessToken string `xorm:"mediumtext" json:"accessToken"`
@ -169,15 +171,17 @@ func GetOAuthCode(userId string, clientId string, responseType string, redirectU
}
token := &Token{
Owner: application.Owner,
Name: util.GenerateId(),
CreatedTime: util.GetCurrentTime(),
Application: application.Name,
Code: util.GenerateClientId(),
AccessToken: accessToken,
ExpiresIn: application.ExpireInHours * 60,
Scope: scope,
TokenType: "Bearer",
Owner: application.Owner,
Name: util.GenerateId(),
CreatedTime: util.GetCurrentTime(),
Application: application.Name,
Organization: user.Owner,
User: user.Name,
Code: util.GenerateClientId(),
AccessToken: accessToken,
ExpiresIn: application.ExpireInHours * 60,
Scope: scope,
TokenType: "Bearer",
}
AddToken(token)

View File

@ -124,6 +124,34 @@ class TokenListPage extends React.Component {
)
}
},
{
title: i18next.t("token:Organization"),
dataIndex: 'organization',
key: 'organization',
width: '120px',
sorter: (a, b) => a.organization.localeCompare(b.organization),
render: (text, record, index) => {
return (
<Link to={`/organizations/${text}`}>
{text}
</Link>
)
}
},
{
title: i18next.t("token:User"),
dataIndex: 'user',
key: 'user',
width: '120px',
sorter: (a, b) => a.user.localeCompare(b.user),
render: (text, record, index) => {
return (
<Link to={`/users/${record.organization}/${text}`}>
{text}
</Link>
)
}
},
{
title: i18next.t("token:Authorization code"),
dataIndex: 'code',
@ -159,13 +187,13 @@ class TokenListPage extends React.Component {
width: '100px',
sorter: (a, b) => a.scope.localeCompare(b.scope),
},
{
title: i18next.t("token:Token type"),
dataIndex: 'tokenType',
key: 'tokenType',
width: '130px',
sorter: (a, b) => a.tokenType.localeCompare(b.tokenType),
},
// {
// title: i18next.t("token:Token type"),
// dataIndex: 'tokenType',
// key: 'tokenType',
// width: '130px',
// sorter: (a, b) => a.tokenType.localeCompare(b.tokenType),
// },
{
title: i18next.t("general:Action"),
dataIndex: '',