Rev 702 | Rev 962 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
635 | daniel-mar | 1 | /* |
2 | * OIDplus 2.0 |
||
3 | * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft |
||
4 | * |
||
5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
||
6 | * you may not use this file except in compliance with the License. |
||
7 | * You may obtain a copy of the License at |
||
8 | * |
||
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
10 | * |
||
11 | * Unless required by applicable law or agreed to in writing, software |
||
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
14 | * See the License for the specific language governing permissions and |
||
15 | * limitations under the License. |
||
16 | */ |
||
17 | |||
18 | var OIDplusPagePublicLogin = { |
||
19 | |||
20 | oid: "1.3.6.1.4.1.37476.2.5.2.4.1.90", |
||
21 | |||
22 | /* RA */ |
||
23 | |||
24 | raLogout: function(email) { |
||
25 | if(!window.confirm(_L("Are you sure that you want to logout?"))) return false; |
||
26 | |||
27 | $.ajax({ |
||
28 | url:"ajax.php", |
||
29 | method:"POST", |
||
30 | beforeSend: function(jqXHR, settings) { |
||
31 | $.xhrPool.abortAll(); |
||
32 | $.xhrPool.add(jqXHR); |
||
33 | }, |
||
34 | complete: function(jqXHR, text) { |
||
35 | $.xhrPool.remove(jqXHR); |
||
36 | }, |
||
37 | data: { |
||
38 | csrf_token:csrf_token, |
||
39 | plugin:OIDplusPagePublicLogin.oid, |
||
40 | action:"ra_logout", |
||
41 | email:email, |
||
42 | }, |
||
43 | error:function(jqXHR, textStatus, errorThrown) { |
||
44 | if (errorThrown == "abort") return; |
||
833 | daniel-mar | 45 | alertError(_L("Error: %1",errorThrown)); |
635 | daniel-mar | 46 | }, |
47 | success:function(data) { |
||
48 | if ("error" in data) { |
||
833 | daniel-mar | 49 | alertError(_L("Error: %1",data.error)); |
635 | daniel-mar | 50 | } else if (data.status >= 0) { |
51 | window.location.href = '?goto=oidplus:system'; |
||
52 | // reloadContent(); |
||
53 | } else { |
||
833 | daniel-mar | 54 | alertError(_L("Error: %1",data)); |
635 | daniel-mar | 55 | } |
56 | } |
||
57 | }); |
||
58 | }, |
||
59 | |||
60 | raLogin: function(email, password, remember_me) { |
||
61 | $.ajax({ |
||
62 | url:"ajax.php", |
||
63 | method:"POST", |
||
64 | beforeSend: function(jqXHR, settings) { |
||
65 | $.xhrPool.abortAll(); |
||
66 | $.xhrPool.add(jqXHR); |
||
67 | }, |
||
68 | complete: function(jqXHR, text) { |
||
69 | $.xhrPool.remove(jqXHR); |
||
70 | }, |
||
71 | data: { |
||
72 | csrf_token:csrf_token, |
||
73 | plugin:OIDplusPagePublicLogin.oid, |
||
74 | action:"ra_login", |
||
75 | email:email, |
||
76 | password:password, |
||
77 | remember_me:remember_me?1:0, |
||
702 | daniel-mar | 78 | captcha: oidplus_captcha_response() |
635 | daniel-mar | 79 | }, |
80 | error:function(jqXHR, textStatus, errorThrown) { |
||
81 | if (errorThrown == "abort") return; |
||
833 | daniel-mar | 82 | alertError(_L("Error: %1",errorThrown)); |
702 | daniel-mar | 83 | oidplus_captcha_reset(); |
635 | daniel-mar | 84 | }, |
85 | success:function(data) { |
||
86 | if ("error" in data) { |
||
833 | daniel-mar | 87 | alertError(_L("Error: %1",data.error)); |
702 | daniel-mar | 88 | oidplus_captcha_reset(); |
635 | daniel-mar | 89 | } else if (data.status >= 0) { |
90 | window.location.href = '?goto=oidplus:system'; |
||
91 | // reloadContent(); |
||
92 | } else { |
||
833 | daniel-mar | 93 | alertError(_L("Error: %1",data)); |
702 | daniel-mar | 94 | oidplus_captcha_reset(); |
635 | daniel-mar | 95 | } |
96 | } |
||
97 | }); |
||
98 | }, |
||
99 | |||
100 | raLoginOnSubmit: function() { |
||
101 | var remember_me = $("#remember_me_ra").length == 0 ? false : $("#remember_me_ra")[0].checked; |
||
102 | OIDplusPagePublicLogin.raLogin($("#raLoginEMail")[0].value, $("#raLoginPassword")[0].value, remember_me); |
||
103 | return false; |
||
104 | }, |
||
105 | |||
106 | /* Admin */ |
||
107 | |||
108 | adminLogin: function(password, remember_me) { |
||
109 | $.ajax({ |
||
110 | url:"ajax.php", |
||
111 | method:"POST", |
||
112 | beforeSend: function(jqXHR, settings) { |
||
113 | $.xhrPool.abortAll(); |
||
114 | $.xhrPool.add(jqXHR); |
||
115 | }, |
||
116 | complete: function(jqXHR, text) { |
||
117 | $.xhrPool.remove(jqXHR); |
||
118 | }, |
||
119 | data: { |
||
120 | csrf_token:csrf_token, |
||
121 | plugin:OIDplusPagePublicLogin.oid, |
||
122 | action:"admin_login", |
||
123 | password:password, |
||
124 | remember_me:remember_me?1:0, |
||
702 | daniel-mar | 125 | captcha: oidplus_captcha_response() |
635 | daniel-mar | 126 | }, |
127 | error:function(jqXHR, textStatus, errorThrown) { |
||
128 | if (errorThrown == "abort") return; |
||
833 | daniel-mar | 129 | alertError(_L("Error: %1",errorThrown)); |
702 | daniel-mar | 130 | oidplus_captcha_reset(); |
635 | daniel-mar | 131 | }, |
132 | success:function(data) { |
||
133 | if ("error" in data) { |
||
833 | daniel-mar | 134 | alertError(_L("Error: %1",data.error)); |
702 | daniel-mar | 135 | oidplus_captcha_reset(); |
635 | daniel-mar | 136 | } else if (data.status >= 0) { |
137 | window.location.href = '?goto=oidplus:system'; |
||
138 | // reloadContent(); |
||
139 | } else { |
||
833 | daniel-mar | 140 | alertError(_L("Error: %1",data)); |
702 | daniel-mar | 141 | oidplus_captcha_reset(); |
635 | daniel-mar | 142 | } |
143 | } |
||
144 | }); |
||
145 | }, |
||
146 | |||
147 | adminLogout: function() { |
||
148 | if(!window.confirm(_L("Are you sure that you want to logout?"))) return false; |
||
149 | |||
150 | $.ajax({ |
||
151 | url:"ajax.php", |
||
152 | method:"POST", |
||
153 | beforeSend: function(jqXHR, settings) { |
||
154 | $.xhrPool.abortAll(); |
||
155 | $.xhrPool.add(jqXHR); |
||
156 | }, |
||
157 | complete: function(jqXHR, text) { |
||
158 | $.xhrPool.remove(jqXHR); |
||
159 | }, |
||
160 | data: { |
||
161 | csrf_token:csrf_token, |
||
162 | plugin:OIDplusPagePublicLogin.oid, |
||
163 | action:"admin_logout", |
||
164 | }, |
||
165 | error:function(jqXHR, textStatus, errorThrown) { |
||
166 | if (errorThrown == "abort") return; |
||
833 | daniel-mar | 167 | alertError(_L("Error: %1",errorThrown)); |
635 | daniel-mar | 168 | }, |
169 | success:function(data) { |
||
170 | if ("error" in data) { |
||
833 | daniel-mar | 171 | alertError(_L("Error: %1",data.error)); |
635 | daniel-mar | 172 | } else if (data.status >= 0) { |
173 | window.location.href = '?goto=oidplus:system'; |
||
174 | // reloadContent(); |
||
175 | } else { |
||
833 | daniel-mar | 176 | alertError(_L("Error: %1",data)); |
635 | daniel-mar | 177 | } |
178 | } |
||
179 | }); |
||
180 | }, |
||
181 | |||
182 | adminLoginOnSubmit: function() { |
||
183 | var remember_me = $("#remember_me_admin").length == 0 ? false : $("#remember_me_admin")[0].checked; |
||
184 | OIDplusPagePublicLogin.adminLogin($("#adminLoginPassword")[0].value, remember_me); |
||
185 | return false; |
||
186 | } |
||
187 | |||
188 | }; |