Welcome Guest, Not a member yet? Register   Sign In
myth/auth - Call to undefined function logged_in()
#1

Hi all,

Migrating from CI3, and I'm having trouble using the helper auth, while in the auth controller.  I'm using a navbar with a login form that displays if the user isn't logged in, and this navbar displays on all pages including all of the authentication pages.

Call to undefined function logged_in()

Code:
<?php if (!logged_in()) : ?>
<form action="<?= route_to('login') ?>" method="post">
                                    <?= csrf_field() ?>
                                <div class="form-group">
                                    <input type="email" class="form-control <?php if(session('errors.login')) : ?>is-invalid<?php endif ?>" name="login" placeholder="<?=lang('Auth.email')?>" autocomplete="username">
                                </div>
                                <div class="form-group">
                                    <input type="password" name="password" class="form-control  <?php if(session('errors.password')) : ?>is-invalid<?php endif ?>" placeholder="<?=lang('Auth.password')?>" autocomplete="current-password">
                                </div>
                                <div class="form-group">
                                    <?php echo form_submit('submit', lang('login_submit_btn'), array('class' => 'btn btn-success btn-block')); ?>
                                </div>
                                </form>
<?php endif; ?>



I installed myth/auth by composer, migrated all, and then renamed the AuthController to Auth:

PHP Code:
<?php namespace App\Controllers;


use 
Config\Email;
use 
Config\Services;
use 
Myth\Auth\Entities\User;
use 
Myth\Auth\Models\UserModel;

class 
Auth extends BaseController


In my BaseController I call the auth helper, so I think it 'should' load through each extending controller.

Code:
<?php
namespace App\Controllers;


use CodeIgniter\Controller;
use App\Libraries\Supersite;
class BaseController extends Controller
{

    protected $helpers = ['html', 'text', 'form', 'auth'];
Reply
#2

Never mind, I see that other are having the same issue (Myth:Auth Helper usage), so I followed the advise there.  Added helper('auth') to my View template, and all is working now.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB