|
69 | 69 | $USER->setSSHKeys($keys, $OPERATOR); // Update user keys |
70 | 70 | break; |
71 | 71 | case "loginshell": |
72 | | - if ($_POST["shellSelect"] == "custom") { |
| 72 | + if ($_POST["shellSelect"] == "Custom") { |
73 | 73 | $USER->setLoginShell($_POST["shell"], $OPERATOR); |
74 | 74 | } else { |
75 | 75 | $USER->setLoginShell($_POST["shellSelect"], $OPERATOR); |
|
186 | 186 | <hr> |
187 | 187 |
|
188 | 188 | <form action="" method="POST"> |
189 | | - |
190 | | - <input type="hidden" name="form_type" value="loginshell"> |
191 | | - |
192 | | - <select id="loginSelector" name= "shellSelect"> |
193 | | - |
194 | | - <option value="" disabled hidden>Select Login Shell...</option> |
195 | | - |
196 | | - <?php |
197 | | - $cur_shell = $USER->getLoginShell(); |
198 | | - $found_selector = false; |
199 | | - foreach ($CONFIG["loginshell"]["shell"] as $shell) { |
200 | | - if ($cur_shell == $shell) { |
201 | | - echo "<option selected>$shell</option>"; |
202 | | - $found_selector = true; |
203 | | - } else { |
204 | | - echo "<option>$shell</option>"; |
205 | | - } |
206 | | - } |
207 | | - |
208 | | - if ($found_selector) { |
209 | | - echo "<option value='custom'>Custom</option>"; |
210 | | - } else { |
211 | | - echo "<option value='custom' selected>Custom</option>"; |
212 | | - } |
213 | | - ?> |
214 | | - </select> |
215 | | - |
216 | | - <?php |
217 | | - |
218 | | - if ($found_selector) { |
219 | | - echo "<input id='customLoginBox' type='text' |
220 | | - placeholder='Enter login shell path (ie. /bin/bash)' name='shell'>"; |
221 | | - } else { |
222 | | - echo "<input id='customLoginBox' type='text' |
223 | | - placeholder='Enter login shell path (ie. /bin/bash)' name='shell' value='$cur_shell'>"; |
224 | | - } |
225 | | - |
226 | | - ?> |
227 | | - <br> |
228 | | - <input type='submit' value='Set Login Shell'> |
229 | | - |
| 189 | +<input type="hidden" name="form_type" value="loginshell"> |
| 190 | +<select id="loginSelector" name="shellSelect"> |
| 191 | +<?php |
| 192 | +foreach ($CONFIG["loginshell"]["shell"] as $shell) { |
| 193 | + echo "<option>$shell</option>"; |
| 194 | +} |
| 195 | +echo "<option id='customLoginSelectorOption'>Custom</option>"; |
| 196 | +?> |
| 197 | +</select> |
| 198 | +<?php |
| 199 | +echo " |
| 200 | + <input |
| 201 | + id='customLoginBox' |
| 202 | + type='text' |
| 203 | + placeholder='Enter login shell path (ie. /bin/bash)' |
| 204 | + name='shell' |
| 205 | + > |
| 206 | +"; |
| 207 | +?> |
| 208 | +<br> |
| 209 | +<input id='submitLoginShell' type='submit' value='Set Login Shell'> |
230 | 210 | </form> |
231 | | - |
232 | 211 | <hr> |
233 | 212 |
|
234 | 213 | <h5>Account Deletion</h5> |
|
257 | 236 |
|
258 | 237 |
|
259 | 238 | <script> |
| 239 | + const sitePrefix = '<?php echo $CONFIG["site"]["prefix"]; ?>'; |
| 240 | + const ldapLoginShell = '<?php echo $USER->getLoginShell(); ?>'; |
| 241 | + |
260 | 242 | $("button.btnAddKey").click(function() { |
261 | | - openModal("Add New Key", "<?php echo $CONFIG["site"]["prefix"]; ?>/panel/modal/new_key.php"); |
| 243 | + openModal("Add New Key", `${sitePrefix}/panel/modal/new_key.php`); |
262 | 244 | }); |
263 | 245 |
|
264 | | - var customLoginBox = $("#customLoginBox"); |
265 | | - if (customLoginBox.val() == "") { |
266 | | - // login box is empty, so we hide it by default |
267 | | - // if the login box had a value, that means it would be a custom shell |
268 | | - // and should not hide by default |
269 | | - customLoginBox.hide(); |
| 246 | + var defaultShellSelected = false; |
| 247 | + $("#loginSelector option").each(function(i, e) { |
| 248 | + if ($(this).val() == ldapLoginShell) { |
| 249 | + $(this).prop("selected", true); |
| 250 | + defaultShellSelected = true; |
| 251 | + } |
| 252 | + }); |
| 253 | + if (!defaultShellSelected) { |
| 254 | + $("#customLoginBox").val(ldapLoginShell); |
| 255 | + $("#customLoginSelectorOption").prop("selected", true); |
270 | 256 | } |
271 | 257 |
|
272 | | - $("#loginSelector").change(function() { |
| 258 | + function showOrHideCustomLoginBox() { |
273 | 259 | var customBox = $("#customLoginBox"); |
274 | | - if($(this).val() == "custom") { |
| 260 | + if($("#loginSelector").val() == "Custom") { |
275 | 261 | customBox.show(); |
276 | 262 | } else { |
277 | 263 | customBox.hide(); |
278 | 264 | } |
279 | | - }); |
280 | | - |
281 | | - if ($("#loginSelector").val() == "custom") { |
282 | | - $("#customLoginBox").show(); |
283 | 265 | } |
| 266 | + $("#loginSelector").change(showOrHideCustomLoginBox); |
| 267 | + showOrHideCustomLoginBox(); |
| 268 | + |
284 | 269 | </script> |
285 | 270 |
|
286 | 271 | <style> |
|
0 commit comments