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