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