Welcome Guest, Not a member yet? Register   Sign In
Error at Login - "The action you requested is not allowed
#5

(This post was last modified: 02-02-2023, 09:37 PM by spreaderman.)

(02-02-2023, 03:20 AM)kenjis Wrote: When you try to login, what happens?

Unfortunately I cannot see your screen, so
"login does work anymore" shows nothing to me.

Here is my login form;

Code:
<?= $this->extend('__templates/user_public/bootswatch'); ?>

<?= $this->section('title'); ?>Login<?= $this->endSection(); ?>

<?= $this->section('content'); ?>

<div class="container">
      
    <?php
    $form = array(
        'class'       => 'form-control border-0',
    );

    $email = array(
        'name'        => 'email',
        'id'          => 'floatingInput',
        'value'       => old('email'),
        'style'       => '',
        'class'       => 'form-control',
        'placeholder' => '[email protected]'
    );

    $password = array(
        'name'        => 'password',
        'id'          => 'floatingInput',
        'type'      => 'password',
        'style'       => '',
        'class'       => 'form-control',
    );
    ?>
    
    <div class="form-group">
        <?= form_open('/login', $form); ?>
        
        <!-- show errors -->
        <?php echo bootstrapAlert(); ?>
        
         <h1>Login</h1>
            <label class="form-label mt-4">Please log in</label>
            <div class="form-floating col-md-5  mt-4">
                <?= form_input($email); ?>
                <label for="floatingInput">Email Address</label>
            </div>
            <div class="form-floating col-md-5 mt-4">
                 <?= form_password($password); ?>
                <label for="floatingPassword">Password</label>
            </div>
            <div class="lfloat  mt-4">
                <button class="btn btn-primary">Login</button> <a href="/password/forgot">Forgot Password?</a>
            </div>
        </form>
     </div>
    
</div> <!-- end container -->

<?= $this->endSection(); ?>

This is my route;

Code:
$routes->match(['get', 'post'], '/login',  'User_public\Login\Login_Controller::login_create',   ['filter' => 'LoggedInNoAccessFilter']);

and this is my login controller;

Code:
public function login_create()
    {
        $auth = new \App\Libraries\Authentication;
        if ($this->request->getMethod() === 'post') {
            //echo $this->input->server('REQUEST_METHOD');
            //echo "here"; die();
            $email        = $this->request->getPost('email');
            $password    = $this->request->getPost('password');
            // check username password and whether user bannded
            if ( ($auth->login($email, $password)) && (!$this->is_banned($this->get_user_ip())) ){
                $redirect_url = session('redirect_url') ?? '/';
                unset($_SESSION['redirect_url']);
                //print_r($this->log_useragent()); die();
                return redirect()->to($redirect_url)
                                ->with('info', 'Login Successfull');
            } else {
                // add entry to login_fail table
                $this->login_fail_create();
                if ($this->is_banned($this->get_user_ip())) {
                    return redirect()->back()
                             ->with('warning', 'User Banned')
                             ->withInput();
                } else {
                    return redirect()->back()
                             ->with('warning', 'Invalid Credentials or Account Not Activated')
                             ->withInput();
                }
            }
        } else {
            // make the right menu item active
            $this->data['active_menu']  = 'login_create';
            return view('User_public/Login/login_create', $this->data    );
        }
    }

I have just notice that this after I post the form, this appears to be false and skips it.

Code:
if ($this->request->getMethod() === 'post') {

but no idea why :-(

When I submit, it is simply redirected to / my home page.

Also, when I open the page to /login, i delete the log file... then I click the login button. I placed log_message but nothing in the log file! When I initially load the page, the log shows GET.

Code:
    public function login_create()
    {
        log_message('error', $this->request->getMethod());
Reply


Messages In This Thread
RE: Error at Login - "The action you requested is not allowed - by spreaderman - 02-02-2023, 09:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB