mirror of
https://github.com/moda-gov-tw/tw-did.git
synced 2026-01-10 05:07:55 -05:00
fix: handle condition with no fido
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
"enterNationalIdToStart": "Please enter your national ID to get started.",
|
||||
"enterValidNationalId": "Please enter a valid nation ID.",
|
||||
"nationalId": "National ID",
|
||||
"noFido": "Please apply for TW FidO before registering for the TaiwanDID.",
|
||||
"scanQrCodeOnTwFidoApp": "Scan this QR code on TW FidO mobile app.",
|
||||
"clickPushNotificationOnPhone": "or click the push notification on your mobile phone",
|
||||
"authenticationFailed": "Authenticate failed!",
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"enterNationalIdToStart": "請輸入你的身分證字號",
|
||||
"enterValidNationalId": "請輸入有效的身分證字號",
|
||||
"nationalId": "身分證字號",
|
||||
"noFido": "請先申請行動自然人憑證,再綁定TaiwanDID",
|
||||
"scanQrCodeOnTwFidoApp": "請在手機上的行動自然人憑證 app 掃描此 QR 碼。",
|
||||
"clickPushNotificationOnPhone": "或點擊您手機上的推送通知",
|
||||
"authenticationFailed": "認證失敗!",
|
||||
|
||||
@@ -20,14 +20,15 @@ export const WelcomeScreen = ({
|
||||
const [idInput, setIdInput] = useState<string>(nationalId);
|
||||
const [warning, setWarning] = useState<string>('');
|
||||
|
||||
function handleGo() {
|
||||
async function handleGo() {
|
||||
if (!validateNationId(idInput)) {
|
||||
setWarning(t('enterValidNationalId'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
handleRegister(idInput);
|
||||
await handleRegister(idInput);
|
||||
} catch (e) {
|
||||
setWarning(t('noFido'))
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,6 +175,11 @@ export const TwDidProvider: React.FC<TwDidProviderProps> = ({ children }) => {
|
||||
);
|
||||
|
||||
const res: RequestLoginResponse = await requestRes.json();
|
||||
|
||||
if(requestRes.status == 500){
|
||||
throw new LoginError('Request Login failed');
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
@@ -205,31 +210,31 @@ export const TwDidProvider: React.FC<TwDidProviderProps> = ({ children }) => {
|
||||
};
|
||||
|
||||
const requestLogin = async (nationalId: string) => {
|
||||
const notifyRes = await _requestLogin(nationalId, 'NOTIFY');
|
||||
const qrcodeRes = await _requestLogin(nationalId, 'QRCODE');
|
||||
const notifyRes = await _requestLogin(nationalId, 'NOTIFY');
|
||||
const qrcodeRes = await _requestLogin(nationalId, 'QRCODE');
|
||||
|
||||
const notification = {
|
||||
transactionId: notifyRes.transactionId,
|
||||
spTicketId: notifyRes.spTicketId,
|
||||
};
|
||||
const qrcode = {
|
||||
transactionId: qrcodeRes.transactionId,
|
||||
spTicketId: qrcodeRes.spTicketId,
|
||||
spTicketPayload: qrcodeRes.spTicketPayload,
|
||||
};
|
||||
const notification = {
|
||||
transactionId: notifyRes.transactionId,
|
||||
spTicketId: notifyRes.spTicketId,
|
||||
};
|
||||
const qrcode = {
|
||||
transactionId: qrcodeRes.transactionId,
|
||||
spTicketId: qrcodeRes.spTicketId,
|
||||
spTicketPayload: qrcodeRes.spTicketPayload,
|
||||
};
|
||||
|
||||
const info: LoginInfo = {
|
||||
nationalId,
|
||||
notification,
|
||||
qrcode,
|
||||
};
|
||||
const info: LoginInfo = {
|
||||
nationalId,
|
||||
notification,
|
||||
qrcode,
|
||||
};
|
||||
|
||||
setLoginInfo(info);
|
||||
setLoginInfo(info);
|
||||
|
||||
// qrcode login
|
||||
_login(nationalId, qrcode.transactionId, qrcode.spTicketId);
|
||||
// notification login
|
||||
_login(nationalId, notification.transactionId, notification.spTicketId);
|
||||
// qrcode login
|
||||
_login(nationalId, qrcode.transactionId, qrcode.spTicketId);
|
||||
// notification login
|
||||
_login(nationalId, notification.transactionId, notification.spTicketId);
|
||||
};
|
||||
|
||||
const logout = () => {
|
||||
|
||||
Reference in New Issue
Block a user