|
@ -22,6 +22,7 @@ const LoginForm: FC<Props> = ({ |
|
|
const [form] = Form.useForm() |
|
|
const [form] = Form.useForm() |
|
|
|
|
|
|
|
|
const nameRef = useRef('') |
|
|
const nameRef = useRef('') |
|
|
|
|
|
const google_token = useRef('') |
|
|
const [codeUrl, setCodeUrl] = useState('') |
|
|
const [codeUrl, setCodeUrl] = useState('') |
|
|
const codeId = useRef('') |
|
|
const codeId = useRef('') |
|
|
const [visible, setVisible] = useState(false) |
|
|
const [visible, setVisible] = useState(false) |
|
@ -53,18 +54,23 @@ const LoginForm: FC<Props> = ({ |
|
|
const { username } = values; |
|
|
const { username } = values; |
|
|
common.login({ ...values, id: codeId.current }).then((res: any) => { |
|
|
common.login({ ...values, id: codeId.current }).then((res: any) => { |
|
|
console.log(res); |
|
|
console.log(res); |
|
|
if (res.code === 0 && !res.data.google) { |
|
|
|
|
|
|
|
|
if (res.code === 0) { |
|
|
|
|
|
if (res.data.google) { |
|
|
|
|
|
nameRef.current = username |
|
|
|
|
|
google_token.current = res.data.google_token |
|
|
|
|
|
setVisible(true) |
|
|
|
|
|
} else { |
|
|
// 登录后返回的数据,包括权限
|
|
|
// 登录后返回的数据,包括权限
|
|
|
const resData = { |
|
|
const resData = { |
|
|
userName: username, |
|
|
userName: username, |
|
|
token: res.data.token, |
|
|
token: res.data.token, |
|
|
permission: res.data.c || [] |
|
|
permission: res.data.c || [] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
setUserInfo(resData, setStoreData) |
|
|
setUserInfo(resData, setStoreData) |
|
|
history.push('/') |
|
|
history.push('/') |
|
|
} else { |
|
|
|
|
|
nameRef.current = username |
|
|
|
|
|
setVisible(true) |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}) |
|
|
}) |
|
@ -114,7 +120,8 @@ const LoginForm: FC<Props> = ({ |
|
|
|
|
|
|
|
|
const onVerifyFinish = async (values) => { |
|
|
const onVerifyFinish = async (values) => { |
|
|
const res: any = await api.verify_googleCode({ |
|
|
const res: any = await api.verify_googleCode({ |
|
|
code: Number(values.code) |
|
|
|
|
|
|
|
|
code: Number(values.code), |
|
|
|
|
|
google_token: google_token.current |
|
|
}) |
|
|
}) |
|
|
if (res.code === 0) { |
|
|
if (res.code === 0) { |
|
|
// 登录后返回的数据,包括权限
|
|
|
// 登录后返回的数据,包括权限
|
|
|