我想用react-admin实现两因素身份验证。任何人都有经验吗?
我已经在后端部分正常工作了,基本上它是这样的:
我已经阅读了有关自定义登录的react-admin文档,但是我找不到如何重定向以防止用户在第2步之后登录
if (type === AUTH_LOGIN) {
const { username, password } = params;
let emaResponse;
const request = new Request(coreConfiguration.apiUrl + "/auth", {
method: "POST",
body: JSON.stringify({
email: username,
password: password
}),
headers: new Headers({
"Content-Type": "application/json"
})
});
return fetch(request)
.then(response => {
if (response.status < 200 || response.status >= 300) {
throw new Error(response.statusText);
}
emaResponse = response.json();
return emaResponse;
})
.then(({ token }) => {
emaResponse.then(userInfo => {
// NOW ASK THE USER FOR 2FA CODE INPUT AND SEND ANOTHER REQUEST
// TO THE API
});
});
}