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