File tree 3 files changed +25
-69
lines changed
3 files changed +25
-69
lines changed Original file line number Diff line number Diff line change 1
- module . exports = require ( './lib/tfa' ) ;
1
+ import TFA from "./lib/tfa.js" ;
2
+
3
+ export default TFA ;
Original file line number Diff line number Diff line change 1
- const axios = require ( 'axios' ) ;
1
+ import API from "./api/index.js" ;
2
2
3
3
class TFA {
4
- constructor ( access_token ) {
5
- this . access_token = access_token ;
6
- this . baseUrl = "http://localhost:9000/api/auth" ;
7
- this . baseUrl = "https://tfasoft-api.herokuapp.com/api/auth" ;
8
- }
9
-
10
- authUser ( user_token ) {
11
- const data = {
12
- "access_token" : this . access_token ,
13
- "user_token" : user_token ,
14
- }
4
+ constructor ( access_token ) {
5
+ this . access_token = access_token ;
6
+ }
15
7
16
- return axios . post ( `${ this . baseUrl } /auth/access` , data )
17
- . then ( ( response ) => {
18
- const data = {
19
- status : response . status ,
20
- data : response . data ,
21
- }
8
+ async authUser ( user_token ) {
9
+ const data = {
10
+ access_token : this . access_token ,
11
+ user_token : user_token ,
12
+ } ;
22
13
23
- return data ;
24
- } )
25
- . catch ( ( error ) => {
26
- const data = {
27
- status : error . response . status ,
28
- data : error . response . data ,
29
- }
14
+ try {
15
+ const response = await API . post ( "access" , data ) ;
30
16
31
- return data ;
32
- } ) ;
17
+ return {
18
+ status : response . status ,
19
+ data : response . data ,
20
+ } ;
21
+ } catch ( error ) {
22
+ return {
23
+ status : error . response . status ,
24
+ data : error . response . data ,
25
+ } ;
33
26
}
27
+ }
34
28
}
35
29
36
- module . exports = TFA ;
30
+ export default TFA ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments