aboutsummaryrefslogtreecommitdiffstats
path: root/authy.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2019-09-12 15:25:47 -0700
committerAdam Soltys <[email protected]>2019-09-12 23:01:06 -0700
commit087fdd27f3683a1deb9376b7a72aa608e6fd8e6a (patch)
tree68bf0872fcfdc65003ed4642bac09aab64d3a3ac /authy.js
parent7da9aa2406fbd890956dcf89c5756949758911dd (diff)
downloadcoinos-server-087fdd27f3683a1deb9376b7a72aa608e6fd8e6a.tar.gz
coinos-server-087fdd27f3683a1deb9376b7a72aa608e6fd8e6a.zip
remove babel and eslint
Diffstat (limited to 'authy.js')
-rw-r--r--authy.js78
1 files changed, 44 insertions, 34 deletions
diff --git a/authy.js b/authy.js
index 336cc2c5..bfca8672 100644
--- a/authy.js
+++ b/authy.js
@@ -1,44 +1,54 @@
-import { Client } from 'authy-client'
-import config from './config'
+const { Client } = require("authy-client");
+const config = require("./config");
-const authy = new Client({ key: config.authy.key })
+const authy = new Client({ key: config.authy.key });
-export default async user => {
- let { authyId } = user
+module.exports = async user => {
+ let { authyId } = user;
- const res = await authy.createApprovalRequest({
- authyId: user.authyId,
- details: {
- visible: {
- User: user.name,
- }
+ const res = await authy.createApprovalRequest(
+ {
+ authyId: user.authyId,
+ details: {
+ visible: {
+ User: user.name
+ }
+ },
+ logos: [
+ {
+ res: "default",
+ url: "https://coinos.io/static/img/coinos.png"
+ }
+ ],
+ message: "Login to CoinOS"
},
- logos: [{
- res: 'default',
- url: 'https://coinos.io/static/img/coinos.png'
- }],
- message: 'Login to CoinOS',
- }, {
- ttl: 120
- });
+ {
+ ttl: 120
+ }
+ );
- let counter = 0
+ let counter = 0;
return new Promise((resolve, reject) => {
let poll = setInterval(async () => {
- counter++
- const r = await authy.getApprovalRequest({ id: res.approval_request.uuid });
- if (r.approval_request.status === 'approved') {
- clearInterval(poll)
- resolve(true)
- }
+ counter++;
+ const r = await authy.getApprovalRequest({
+ id: res.approval_request.uuid
+ });
+ if (r.approval_request.status === "approved") {
+ clearInterval(poll);
+ resolve(true);
+ }
- if (r.approval_request.status === 'denied') {
- clearInterval(poll)
- resolve(false)
- }
+ if (r.approval_request.status === "denied") {
+ clearInterval(poll);
+ resolve(false);
+ }
- if (counter > 60) { clearInterval(poll); reject(false) }
- }, 1000)
- })
-}
+ if (counter > 60) {
+ clearInterval(poll);
+ reject(false);
+ }
+ }, 1000);
+ });
+};