mirror of
https://github.com/songquanpeng/one-api.git
synced 2026-02-20 04:44:26 +08:00
refactor: Changing OAuth 2.0 to OIDC
This commit is contained in:
@@ -20,7 +20,7 @@ import SubCard from 'ui-component/cards/SubCard';
|
||||
import { IconBrandWechat, IconBrandGithub, IconMail } from '@tabler/icons-react';
|
||||
import Label from 'ui-component/Label';
|
||||
import { API } from 'utils/api';
|
||||
import { showError, showSuccess } from 'utils/common';
|
||||
import { onOidcClicked, showError, showSuccess } from 'utils/common';
|
||||
import { onGitHubOAuthClicked, onLarkOAuthClicked, copy } from 'utils/common';
|
||||
import * as Yup from 'yup';
|
||||
import WechatModal from 'views/Authentication/AuthForms/WechatModal';
|
||||
@@ -28,6 +28,7 @@ import { useSelector } from 'react-redux';
|
||||
import EmailModal from './component/EmailModal';
|
||||
import Turnstile from 'react-turnstile';
|
||||
import { ReactComponent as Lark } from 'assets/images/icons/lark.svg';
|
||||
import { ReactComponent as OIDC } from 'assets/images/icons/oidc.svg';
|
||||
|
||||
const validationSchema = Yup.object().shape({
|
||||
username: Yup.string().required('用户名 不能为空').min(3, '用户名 不能小于 3 个字符'),
|
||||
@@ -123,6 +124,15 @@ export default function Profile() {
|
||||
loadUser().then();
|
||||
}, [status]);
|
||||
|
||||
function getOidcId(){
|
||||
if (!inputs.oidc_id) return '';
|
||||
let oidc_id = inputs.oidc_id;
|
||||
if (inputs.oidc_id.length > 8) {
|
||||
oidc_id = inputs.oidc_id.slice(0, 6) + '...' + inputs.oidc_id.slice(-6);
|
||||
}
|
||||
return oidc_id;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<UserCard>
|
||||
@@ -141,6 +151,9 @@ export default function Profile() {
|
||||
<Label variant="ghost" color={inputs.lark_id ? 'primary' : 'default'}>
|
||||
<SvgIcon component={Lark} inheritViewBox="0 0 24 24" /> {inputs.lark_id || '未绑定'}
|
||||
</Label>
|
||||
<Label variant="ghost" color={inputs.oidc_id ? 'primary' : 'default'}>
|
||||
<SvgIcon component={OIDC} inheritViewBox="0 0 24 24" /> {getOidcId() || '未绑定'}
|
||||
</Label>
|
||||
</Stack>
|
||||
<SubCard title="个人信息">
|
||||
<Grid container spacing={2}>
|
||||
@@ -216,6 +229,13 @@ export default function Profile() {
|
||||
</Button>
|
||||
</Grid>
|
||||
)}
|
||||
{status.oidc && !inputs.oidc_id && (
|
||||
<Grid xs={12} md={4}>
|
||||
<Button variant="contained" onClick={() => onOidcClicked(status.oidc_authorization_endpoint,status.oidc_app_id,true)}>
|
||||
绑定 OIDC 账号
|
||||
</Button>
|
||||
</Grid>
|
||||
)}
|
||||
<Grid xs={12} md={4}>
|
||||
<Button
|
||||
variant="contained"
|
||||
|
||||
Reference in New Issue
Block a user