]>
Commit | Line | Data |
---|---|---|
1 | import SignupForm from './signup.js'; | |
2 | import SigninForm from './signin.js'; | |
3 | import PasswordResetForm from './password_reset.js'; | |
4 | import ChangePasswordForm from './change_password.js'; | |
5 | import OtpEnrollForm from './otp.js'; | |
6 | import PoloniexController from './poloniex.js'; | |
7 | import PoloniexConfiguration from './account.js'; | |
8 | import App from './app.js'; | |
9 | import Api from './api.js'; | |
10 | import cookies from './cookies.js'; | |
11 | import React from 'react'; | |
12 | import qs from 'qs'; | |
13 | ||
14 | App.page('/signup', false, function(context) { | |
15 | if (App.isUserSignedIn()) { | |
16 | App.go('/me'); | |
17 | return; | |
18 | } | |
19 | ||
20 | App.mount(<div> | |
21 | <SignupForm onSuccess={App.onUserSignUp}/> | |
22 | </div>); | |
23 | }); | |
24 | ||
25 | App.page('/signin', false, function(context) { | |
26 | if (App.isUserSignedIn()) { | |
27 | App.go('/me'); | |
28 | return; | |
29 | } | |
30 | ||
31 | App.mount(<div> | |
32 | <SigninForm onSuccess={App.onUserSignIn}/> | |
33 | </div>); | |
34 | }); | |
35 | ||
36 | App.page('/reset-password', false, function(context) { | |
37 | if (App.isUserSignedIn()) { | |
38 | App.go('/me'); | |
39 | return; | |
40 | } | |
41 | ||
42 | App.mount(<div> | |
43 | <PasswordResetForm /> | |
44 | </div>); | |
45 | }); | |
46 | ||
47 | App.page('/change-password', false, function(context) { | |
48 | if (App.isUserSignedIn()) { | |
49 | App.go('/me'); | |
50 | return; | |
51 | } | |
52 | ||
53 | var token = qs.parse(context.querystring).token; | |
54 | ||
55 | if (token === undefined) { | |
56 | App.go('/'); | |
57 | return; | |
58 | } | |
59 | ||
60 | App.mount(<div> | |
61 | <ChangePasswordForm token={token} onSuccess={App.go.bind(App, '/signin')}/> | |
62 | </div>); | |
63 | }); | |
64 | ||
65 | App.page('/signout', true, function(context) { | |
66 | cookies.removeItem('jwt'); | |
67 | ||
68 | App.go('/'); | |
69 | }); | |
70 | ||
71 | App.page('/me', true, function(context) { | |
72 | App.mount(<div> | |
73 | <PoloniexController/> | |
74 | </div>); | |
75 | }); | |
76 | ||
77 | App.page('/account', true, function(context) { | |
78 | App.mount(<div> | |
79 | <PoloniexConfiguration/> | |
80 | </div>); | |
81 | }); | |
82 | ||
83 | App.page('/not_confirmed', true, function(context) { | |
84 | App.mount(<div> | |
85 | <div className="row"> | |
86 | <div className="box offset-3 col-6 text-center"> | |
87 | <p>Please be patient, you account is being confirmed...</p> | |
88 | <p><a href="/me"><u>Refresh</u></a></p> | |
89 | </div> | |
90 | </div> | |
91 | </div>); | |
92 | }); | |
93 | ||
94 | App.page('/otp/setup', true, function(context) { | |
95 | Api.Call('OTP_ENROLL', {}, function(err, status, data) { | |
96 | if (err) { | |
97 | console.error(err, data); | |
98 | return; | |
99 | } | |
100 | ||
101 | App.mount(<div> | |
102 | <OtpEnrollForm onSuccess={App.onUserValidateOtp} img={'data:image/png;base64,' + data.base64img} secret={data.secret}/> | |
103 | </div>); | |
104 | ||
105 | }); | |
106 | }); | |
107 | ||
108 | App.page('/otp/validate', true, function(context) { | |
109 | App.mount(<div> | |
110 | <OtpEnrollForm onSuccess={App.onUserValidateOtp} /> | |
111 | </div>); | |
112 | }); | |
113 | ||
114 | App.page('/', false, function(context) { | |
115 | App.go('/me'); | |
116 | }); | |
117 | ||
118 | $(document).ready(function() { | |
119 | App.start(); | |
120 | }); |