コード例 #1
0
ファイル: user.php プロジェクト: mrjovanovic/miniflux
function validate_login(array $values)
{
    $v = new Validator($values, array(new Validators\Required('username', t('The user name is required')), new Validators\MaxLength('username', t('The maximum length is 50 characters'), 50), new Validators\Required('password', t('The password is required'))));
    $result = $v->execute();
    $errors = $v->getErrors();
    if ($result) {
        $credentials = getCredentials();
        if ($credentials && $credentials['username'] === $values['username'] && password_verify($values['password'], $credentials['password'])) {
            $_SESSION['loggedin'] = true;
            $_SESSION['config'] = Config\get_all();
            // Setup the remember me feature
            if (!empty($values['remember_me'])) {
                $cookie = RememberMe\create(DatabaseModel\select(), $values['username'], Config\get_ip_address(), Config\get_user_agent());
                RememberMe\write_cookie($cookie['token'], $cookie['sequence'], $cookie['expiration']);
            }
        } else {
            $result = false;
            $errors['login'] = t('Bad username or password');
        }
    }
    return array($result, $errors);
}
コード例 #2
0
ファイル: database.php プロジェクト: webbrewmtl/miniflux
function select($filename = '')
{
    static $current_filename = DB_FILENAME;
    // function gets called with a filename at least once the database
    // connection is established
    if (!empty($filename)) {
        if (ENABLE_MULTIPLE_DB && in_array($filename, get_all())) {
            $current_filename = $filename;
            // unset the authenticated flag if the database is changed
            if (empty($_SESSION['database']) || $_SESSION['database'] !== $filename) {
                if (isset($_SESSION)) {
                    unset($_SESSION['loggedin']);
                }
                $_SESSION['database'] = $filename;
                $_SESSION['config'] = Config\get_all();
            }
        } else {
            return false;
        }
    }
    return $current_filename;
}