Rev 360 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
104 | daniel-mar | 1 | /* |
2 | * OIDplus 2.0 |
||
3 | * Copyright 2019 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 | /* RA */ |
||
19 | |||
20 | function raLogout(email) { |
||
360 | daniel-mar | 21 | if(!window.confirm(_L("Are you sure that you want to logout?"))) return false; |
104 | daniel-mar | 22 | |
23 | $.ajax({ |
||
107 | daniel-mar | 24 | url:"ajax.php", |
104 | daniel-mar | 25 | method:"POST", |
26 | data: { |
||
320 | daniel-mar | 27 | plugin:"1.3.6.1.4.1.37476.2.5.2.4.1.90", |
104 | daniel-mar | 28 | action:"ra_logout", |
29 | email:email, |
||
30 | }, |
||
107 | daniel-mar | 31 | error:function(jqXHR, textStatus, errorThrown) { |
360 | daniel-mar | 32 | alert(_L("Error: %1",errorThrown)); |
107 | daniel-mar | 33 | }, |
104 | daniel-mar | 34 | success:function(data) { |
107 | daniel-mar | 35 | if ("error" in data) { |
360 | daniel-mar | 36 | alert(_L("Error: %1",data.error)); |
381 | daniel-mar | 37 | } else if (data.status >= 0) { |
154 | daniel-mar | 38 | window.location.href = '?goto=oidplus:system'; |
104 | daniel-mar | 39 | // reloadContent(); |
107 | daniel-mar | 40 | } else { |
360 | daniel-mar | 41 | alert(_L("Error: %1",data)); |
104 | daniel-mar | 42 | } |
43 | } |
||
44 | }); |
||
45 | } |
||
46 | |||
47 | function raLogin(email, password) { |
||
48 | $.ajax({ |
||
107 | daniel-mar | 49 | url:"ajax.php", |
104 | daniel-mar | 50 | method:"POST", |
51 | data: { |
||
320 | daniel-mar | 52 | plugin:"1.3.6.1.4.1.37476.2.5.2.4.1.90", |
104 | daniel-mar | 53 | action:"ra_login", |
54 | email:email, |
||
55 | password:password, |
||
56 | captcha: document.getElementsByClassName('g-recaptcha').length > 0 ? grecaptcha.getResponse() : null |
||
57 | }, |
||
107 | daniel-mar | 58 | error:function(jqXHR, textStatus, errorThrown) { |
360 | daniel-mar | 59 | alert(_L("Error: %1",errorThrown)); |
107 | daniel-mar | 60 | if (document.getElementsByClassName('g-recaptcha').length > 0) grecaptcha.reset(); |
61 | }, |
||
104 | daniel-mar | 62 | success:function(data) { |
107 | daniel-mar | 63 | if ("error" in data) { |
360 | daniel-mar | 64 | alert(_L("Error: %1",data.error)); |
107 | daniel-mar | 65 | if (document.getElementsByClassName('g-recaptcha').length > 0) grecaptcha.reset(); |
381 | daniel-mar | 66 | } else if (data.status >= 0) { |
154 | daniel-mar | 67 | window.location.href = '?goto=oidplus:system'; |
104 | daniel-mar | 68 | // reloadContent(); |
107 | daniel-mar | 69 | } else { |
360 | daniel-mar | 70 | alert(_L("Error: %1",data)); |
107 | daniel-mar | 71 | if (document.getElementsByClassName('g-recaptcha').length > 0) grecaptcha.reset(); |
104 | daniel-mar | 72 | } |
73 | } |
||
74 | }); |
||
75 | } |
||
76 | |||
77 | function raLoginOnSubmit() { |
||
78 | raLogin(document.getElementById("raLoginEMail").value, document.getElementById("raLoginPassword").value); |
||
79 | return false; |
||
80 | } |
||
81 | |||
82 | /* Admin */ |
||
83 | |||
84 | function adminLogin(password) { |
||
85 | $.ajax({ |
||
107 | daniel-mar | 86 | url:"ajax.php", |
104 | daniel-mar | 87 | method:"POST", |
88 | data: { |
||
320 | daniel-mar | 89 | plugin:"1.3.6.1.4.1.37476.2.5.2.4.1.90", |
104 | daniel-mar | 90 | action:"admin_login", |
91 | password:password, |
||
92 | captcha: document.getElementsByClassName('g-recaptcha').length > 0 ? grecaptcha.getResponse() : null |
||
93 | }, |
||
107 | daniel-mar | 94 | error:function(jqXHR, textStatus, errorThrown) { |
360 | daniel-mar | 95 | alert(_L("Error: %1",errorThrown)); |
107 | daniel-mar | 96 | if (document.getElementsByClassName('g-recaptcha').length > 0) grecaptcha.reset(); |
97 | }, |
||
104 | daniel-mar | 98 | success:function(data) { |
107 | daniel-mar | 99 | if ("error" in data) { |
360 | daniel-mar | 100 | alert(_L("Error: %1",data.error)); |
107 | daniel-mar | 101 | if (document.getElementsByClassName('g-recaptcha').length > 0) grecaptcha.reset(); |
381 | daniel-mar | 102 | } else if (data.status >= 0) { |
154 | daniel-mar | 103 | window.location.href = '?goto=oidplus:system'; |
104 | daniel-mar | 104 | // reloadContent(); |
107 | daniel-mar | 105 | } else { |
360 | daniel-mar | 106 | alert(_L("Error: %1",data)); |
107 | daniel-mar | 107 | if (document.getElementsByClassName('g-recaptcha').length > 0) grecaptcha.reset(); |
104 | daniel-mar | 108 | } |
109 | } |
||
110 | }); |
||
111 | } |
||
112 | |||
113 | function adminLogout() { |
||
360 | daniel-mar | 114 | if(!window.confirm(_L("Are you sure that you want to logout?"))) return false; |
104 | daniel-mar | 115 | |
116 | $.ajax({ |
||
107 | daniel-mar | 117 | url:"ajax.php", |
104 | daniel-mar | 118 | method:"POST", |
119 | data: { |
||
320 | daniel-mar | 120 | plugin:"1.3.6.1.4.1.37476.2.5.2.4.1.90", |
104 | daniel-mar | 121 | action:"admin_logout", |
122 | }, |
||
107 | daniel-mar | 123 | error:function(jqXHR, textStatus, errorThrown) { |
360 | daniel-mar | 124 | alert(_L("Error: %1",errorThrown)); |
107 | daniel-mar | 125 | }, |
104 | daniel-mar | 126 | success:function(data) { |
107 | daniel-mar | 127 | if ("error" in data) { |
360 | daniel-mar | 128 | alert(_L("Error: %1",data.error)); |
381 | daniel-mar | 129 | } else if (data.status >= 0) { |
154 | daniel-mar | 130 | window.location.href = '?goto=oidplus:system'; |
104 | daniel-mar | 131 | // reloadContent(); |
107 | daniel-mar | 132 | } else { |
360 | daniel-mar | 133 | alert(_L("Error: %1",data)); |
104 | daniel-mar | 134 | } |
135 | } |
||
136 | }); |
||
137 | } |
||
138 | |||
139 | function adminLoginOnSubmit() { |
||
140 | adminLogin(document.getElementById("adminLoginPassword").value); |
||
141 | return false; |
||
360 | daniel-mar | 142 | } |