]>
Commit | Line | Data |
---|---|---|
989fb5c7 | 1 | import SignupForm from './signup.js'; |
2 | import SigninForm from './signin.js'; | |
85545aba | 3 | import PasswordResetForm from './password_reset.js'; |
4 | import ChangePasswordForm from './change_password.js'; | |
989fb5c7 | 5 | import OtpEnrollForm from './otp.js'; |
6 | import PoloniexController from './poloniex.js'; | |
d1c0ccfc | 7 | import UserAccount from './account.js'; |
2e4885d9 | 8 | import AdminDashboard from './admin.js'; |
989fb5c7 | 9 | import App from './app.js'; |
10 | import Api from './api.js'; | |
11 | import cookies from './cookies.js'; | |
12 | import React from 'react'; | |
85545aba | 13 | import qs from 'qs'; |
7a9e5112 | 14 | |
7a9e5112 | 15 | App.page('/signup', false, function(context) { |
16 | if (App.isUserSignedIn()) { | |
17 | App.go('/me'); | |
18 | return; | |
19 | } | |
20 | ||
989fb5c7 | 21 | App.mount(<div> |
7a9e5112 | 22 | <SignupForm onSuccess={App.onUserSignUp}/> |
989fb5c7 | 23 | </div>); |
7a9e5112 | 24 | }); |
25 | ||
26 | App.page('/signin', false, function(context) { | |
27 | if (App.isUserSignedIn()) { | |
28 | App.go('/me'); | |
29 | return; | |
30 | } | |
31 | ||
989fb5c7 | 32 | App.mount(<div> |
7a9e5112 | 33 | <SigninForm onSuccess={App.onUserSignIn}/> |
989fb5c7 | 34 | </div>); |
7a9e5112 | 35 | }); |
36 | ||
85545aba | 37 | App.page('/reset-password', false, function(context) { |
38 | if (App.isUserSignedIn()) { | |
39 | App.go('/me'); | |
40 | return; | |
41 | } | |
42 | ||
43 | App.mount(<div> | |
85545aba | 44 | <PasswordResetForm /> |
45 | </div>); | |
46 | }); | |
47 | ||
48 | App.page('/change-password', false, function(context) { | |
49 | if (App.isUserSignedIn()) { | |
50 | App.go('/me'); | |
51 | return; | |
52 | } | |
53 | ||
54 | var token = qs.parse(context.querystring).token; | |
55 | ||
56 | if (token === undefined) { | |
57 | App.go('/'); | |
58 | return; | |
59 | } | |
60 | ||
61 | App.mount(<div> | |
85545aba | 62 | <ChangePasswordForm token={token} onSuccess={App.go.bind(App, '/signin')}/> |
63 | </div>); | |
64 | }); | |
65 | ||
2da5b12c | 66 | App.page('/confirm', false, function(context) { |
67 | var token = qs.parse(context.querystring).token; | |
68 | ||
69 | if (token === undefined) { | |
70 | App.go('/'); | |
71 | return; | |
72 | } | |
73 | ||
74 | Api.Call( | |
75 | 'CONFIRM_EMAIL', | |
76 | {'token': token}, | |
77 | function(err, status, data) { | |
78 | if (err) { | |
79 | console.error(err, data); | |
80 | } | |
81 | ||
82 | App.go('/me'); | |
83 | } | |
84 | ); | |
85 | }); | |
86 | ||
7a9e5112 | 87 | App.page('/signout', true, function(context) { |
88 | cookies.removeItem('jwt'); | |
89 | ||
90 | App.go('/'); | |
91 | }); | |
92 | ||
93 | App.page('/me', true, function(context) { | |
989fb5c7 | 94 | App.mount(<div> |
2f91f20a | 95 | <PoloniexController/> |
989fb5c7 | 96 | </div>); |
7a9e5112 | 97 | }); |
98 | ||
16e43cc7 | 99 | App.page('/account', true, function(context) { |
100 | App.mount(<div> | |
d1c0ccfc | 101 | <UserAccount/> |
16e43cc7 | 102 | </div>); |
103 | }); | |
104 | ||
2e4885d9 | 105 | App.page('/admin', true, function(context) { |
106 | App.mount(<div> | |
107 | <AdminDashboard/> | |
108 | </div>); | |
109 | }); | |
110 | ||
adf936f6 | 111 | App.page('/not_confirmed', true, function(context) { |
112 | App.mount(<div> | |
adf936f6 | 113 | <div className="row"> |
114 | <div className="box offset-3 col-6 text-center"> | |
2da5b12c | 115 | <p>An email has now been sent to your email address.</p> |
a7873be2 | 116 | <p>{'Please click the \'Confirm your account\' button to validate your email.'}</p> |
adf936f6 | 117 | </div> |
118 | </div> | |
119 | </div>); | |
120 | }); | |
121 | ||
7a9e5112 | 122 | App.page('/otp/setup', true, function(context) { |
123 | Api.Call('OTP_ENROLL', {}, function(err, status, data) { | |
124 | if (err) { | |
125 | console.error(err, data); | |
126 | return; | |
127 | } | |
128 | ||
989fb5c7 | 129 | App.mount(<div> |
7a9e5112 | 130 | <OtpEnrollForm onSuccess={App.onUserValidateOtp} img={'data:image/png;base64,' + data.base64img} secret={data.secret}/> |
989fb5c7 | 131 | </div>); |
7a9e5112 | 132 | |
989fb5c7 | 133 | }); |
7a9e5112 | 134 | }); |
135 | ||
136 | App.page('/otp/validate', true, function(context) { | |
989fb5c7 | 137 | App.mount(<div> |
7a9e5112 | 138 | <OtpEnrollForm onSuccess={App.onUserValidateOtp} /> |
989fb5c7 | 139 | </div>); |
7a9e5112 | 140 | }); |
141 | ||
142 | App.page('/', false, function(context) { | |
143 | App.go('/me'); | |
144 | }); | |
145 | ||
146 | $(document).ready(function() { | |
147 | App.start(); | |
148 | }); |