Last active
December 4, 2023 15:43
-
-
Save stepashka15120/b686962c8f896a08d8e5cfbea16ea217 to your computer and use it in GitHub Desktop.
Авторизация в 1С-Битрикс (Форма в popup окне, проверка на правильность введенных данных).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?// /local/php_interface/include/login.php?> | |
| <?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php"); | |
| global $USER; | |
| if (!is_object($USER)) $USER = new CUser; | |
| $arAuthResult = $USER->Login($_REQUEST["USER_LOGIN"], $_REQUEST["USER_PASSWORD"], $_REQUEST["USER_REMEMBER"]); | |
| $APPLICATION->arAuthResult = $arAuthResult; | |
| if($arAuthResult["TYPE"] == "ERROR"){ | |
| $res["MESSAGE"] = $arAuthResult["MESSAGE"]; | |
| $res["status"] = "error"; | |
| }else{ | |
| $res["status"] = "ok"; | |
| } | |
| echo json_encode($res,JSON_UNESCAPED_UNICODE); | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // /local/templates/name_template/js/script.js | |
| $(document).on('submit', '#partner-login', function(e){ | |
| e.preventDefault(); | |
| var form = $(this); | |
| var formData = form.serialize(); | |
| $.ajax({ | |
| method: 'post', | |
| url: '/local/php_interface/include/login.php', | |
| data: formData | |
| }).done(function(data){ | |
| console.log(data); | |
| var res = JSON.parse(data); | |
| if(res.status == 'error'){ | |
| $('.error-ok-pass').html('Неверный логин или пароль'); | |
| } | |
| if(res.status == 'ok'){ | |
| document.location.href = '/dealer_portal/'; | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment