Jump to content

Авторизация подтвержденным юзером PHP


Recommended Posts

Суть:

есть скрипт на авторизацию в удаленном приложении. 

<?php
header("Content-Type: text/plain; charset=UTF-8");

// Verify login and password
$login = $_GET['login'];
$password = $_GET['password'];
if(empty($login) || empty($password)) {
    exit('Empty login or password');
}

// Load IPB init script
\define('REPORT_EXCEPTIONS', TRUE);
$_SERVER['SCRIPT_FILENAME']	= __FILE__;
require_once 'init.php';

// Try authenticate
$member = NULL;
$ipsLogin = new \IPS\Login();
foreach($ipsLogin->usernamePasswordMethods() as $method) {
    try {
        $member = $method->authenticateUsernamePassword($ipsLogin, $login, $password);
        \IPS\Login::checkIfAccountIsLocked($member, TRUE);
        if ($member->isBanned()) {
            $member = NULL;
            continue;
        }
        break;
    } catch (\Exception $e) {
        // Do nothing
    }
}

// We're done
echo($member ? 'OK:' . $member->name : 'Incorrect login or password');
?>

работает чудесно, но как добавить проверку - подтвердил ли пользователь свой email?

Может кто откликнется за денежку. Открыт к предложениям.

Link to comment
Share on other sites

if ( !\IPS\Db::i()->select( 'COUNT(*)', 'core_validating', array( 'member_id=? AND lost_pass!=1 AND forgot_security!=1', $member->member_id ) )->first() )
{
	// Подтвердил
}

 

Link to comment
Share on other sites

В 27.07.2019 в 11:47, WaNted сказал:

if ( !\IPS\Db::i()->select( 'COUNT(*)', 'core_validating', array( 'member_id=? AND lost_pass!=1 AND forgot_security!=1', $member->member_id ) )->first() )
{
	// Подтвердил
}

 

не могли бы поделиться остальной частью кода? разобраться не могу, толи как то надо подключить \IPS\Db толи еще что.

Link to comment
Share on other sites

8 минут назад, WaNted сказал:

Вы же уже подключили init.php, этого достаточно.

Да. Только что допилил, я почему то решил что first(); мне не нужен и в этом была ошибка. Спасибо за помощь. Вопрос решен.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Ваша ссылка была автоматически строена.   Отображать как обычную ссылку

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...