verification: don't request a code twice (#4221)
* verification: check if user has received code * verification: don't request a code twice * code style :lint:
This commit is contained in:
27
js/src/3rdparty/sms-verification/index.js
vendored
27
js/src/3rdparty/sms-verification/index.js
vendored
@@ -18,8 +18,10 @@ import { stringify } from 'querystring';
|
||||
|
||||
export const isServerRunning = (isTestnet = false) => {
|
||||
const port = isTestnet ? 8443 : 443;
|
||||
|
||||
return fetch(`https://sms-verification.parity.io:${port}/health`, {
|
||||
mode: 'cors', cache: 'no-store'
|
||||
mode: 'cors',
|
||||
cache: 'no-store'
|
||||
})
|
||||
.then((res) => {
|
||||
return res.ok;
|
||||
@@ -29,11 +31,30 @@ export const isServerRunning = (isTestnet = false) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const hasReceivedCode = (number, address, isTestnet = false) => {
|
||||
const port = isTestnet ? 8443 : 443;
|
||||
const query = stringify({ number, address });
|
||||
|
||||
return fetch(`https://sms-verification.parity.io:${port}/?${query}`, {
|
||||
mode: 'cors',
|
||||
cache: 'no-store'
|
||||
})
|
||||
.then((res) => {
|
||||
return res.ok;
|
||||
})
|
||||
.catch(() => {
|
||||
return false; // todo: check for 404
|
||||
});
|
||||
};
|
||||
|
||||
export const postToServer = (query, isTestnet = false) => {
|
||||
const port = isTestnet ? 8443 : 443;
|
||||
query = stringify(query);
|
||||
return fetch(`https://sms-verification.parity.io:${port}/?` + query, {
|
||||
method: 'POST', mode: 'cors', cache: 'no-store'
|
||||
|
||||
return fetch(`https://sms-verification.parity.io:${port}/?${query}`, {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
cache: 'no-store'
|
||||
})
|
||||
.then((res) => {
|
||||
return res.json().then((data) => {
|
||||
|
||||
Reference in New Issue
Block a user