B
B
Bogdan Deriy2015-10-26 16:11:55
PHP
Bogdan Deriy, 2015-10-26 16:11:55

Authorization by e-mail?

Good afternoon. The site provides authorization using modal windows. Login is via email and password. Connected the necessary standard components, set up templates for them. But when filling in the fields of the modal window and clicking on "Login", we go to the authorization page by login ../auth. Yes, if you enter a username and password, then authorization works. Please tell me how to log in directly from the modal window by e-mail ??? An authorized user after the correct data entry must log in immediately. AT

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Bogdan Deriy, 2015-10-27
@bodia7

AddEventHandler("main", "OnBeforeUserLogin", array("CCustomHookEvent", "DoBeforeUserLoginHandler"));
class CCustomHookEvent {
        //  Проверяем пришел ли email или login и если email авторизуем по нему
        function DoBeforeUserLoginHandler( &$arFields )
        {
            $userLogin = $_POST["USER_LOGIN"];
            if (isset($userLogin))
            {
                $isEmail = strpos($userLogin,"@");
                if ($isEmail>0)
                {
                    $arFilter = Array("EMAIL"=>$userLogin);
                    $rsUsers = CUser::GetList(($by="id"), ($order="desc"), $arFilter);
                    if($res = $rsUsers->Fetch())
                    {
                        if($res["EMAIL"]==$arFields["LOGIN"])
                            $arFields["LOGIN"] = $res["LOGIN"];
                    }
                }
            }
        }
        // End 
}

M
Maxim Grechushnikov, 2015-10-26
@maxyc_webber

what's the problem with inserting an authorization component into a modal window?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question