Welcome Guest, Not a member yet? Register   Sign In
Community Auth Learning...
#31

Now my admin/login method works fine now.
I can now login through it.

But the new problem is when I login using an invalid password it redirect me to the front/login method which is the public login page of the website.
How do I make it show the error on the same admin/login page?

By the way here is the codes in my admin/login method.
Code:
public function login()
    {
        if( $this->verify_min_level(9) )
        {
            $this->cpanel();
        }
        else if( $this->tokens->match && $this->optional_login() )
        {
            // Let Community Auth handle the login attempt ...
        }
        else
        {
            // Show your form here ...
            //echo '<p>You are not logged in, Show your form here</p>';

            // Notice the parameter is set to TRUE, which designates this as an optional login
            $this->setup_login_form(TRUE);
            
            $this->dryview($header='admin/header', $msg='', $menu='admin/menu', $content='admin/login',  $footer='admin/footer', $master='admin/admin_login_page');
        }  
    }

thanks in advance.
Reply
#32

Currently the recover the username or password is not sending an actual email verification message.
What settings to make it send the actual email?
Or should I code this manually?
What method class/method this feature resides?

still digging the codes...
Reply
#33

(This post was last modified: 11-24-2015, 12:33 AM by solidcodes.)

Just an update for the admin/admin/login
it's working fine now both on invalid password or valid password.

@skunkbad
here you can try this,
username: iridion9
password: Retinitis9

front/public login
http://beautiful-dates.com/ci/login?redirect=

admin login
http://beautiful-dates.com/ci/admin/admin/login

The problem I need to fix is how to send the actual email for username/password recovery.
Is there a settings in the config I should tweak for this?


thanks in advance.
Reply
#34

(11-24-2015, 12:29 AM)solidcodes Wrote: Just an update for the  admin/admin/login
it's working fine now both on invalid password or valid password.

@skunkbad
here you can try this,
username: iridion9
password: Retinitis9

front/public login
http://beautiful-dates.com/ci/login?redirect=

admin login
http://beautiful-dates.com/ci/admin/admin/login

The problem I need to fix is how to send the actual email for username/password recovery.
Is there a settings in the config I should tweak for this?


thanks in advance.

The example controller doesn't add the email functionality, but adding it is pretty easy. You would just change some lines. For instance, in the Examples controller on line 301 you see where the special link is created. Now just put that in an email to the user. Something like this is what I used:


PHP Code:
// Send recovery email
$this->load->library('email');
$this->config->load('email');
$email_configs config_item('email_configs');
$email_config $email_configs['user_recovery'];
$email_config['to'] = $user_data->user_email;
$email_config['special_link'] = secure_anchor
       'examples/recovery_verification/' $user_data->user_id '/' $recovery_code
       secure_site_url'examples/recovery_verification/' $user_data->user_id '/' $recovery_code ), 
       'target ="_blank"' 
);
$this->email->quick_email$email_config ); 

At least in this case you are not going to have Email::quick_email, but you would just send an email using CI the way it shows in the CI user guide.
Reply
#35

thanks will figure it out.
Reply
#36

@skunkbad
sending email is fine now.
By the way how do I stop the admin login page from redirecting to public login page?
When an invalid password is purposely entered?

Thanks in advance.
Reply
#37

solidcodes, this takes a little tweaking. So for instance let's say I have an admin login at examples/alt_login:

config/authentication.php


PHP Code:
$config['allowed_pages_for_login'] = array(
    'examples/alt_login'
); 

controllers/Examples.php

PHP Code:
public function alt_login()
{
    if( strtolower$_SERVER['REQUEST_METHOD'] ) == 'post' )
    {
        $this->require_min_level(1);
    }

    $this->setup_login_form();

    $html $this->load->view('examples/page_header'''TRUE);
    $html .= $this->load->view('examples/login_form'''TRUE);
    $html .= $this->load->view('examples/page_footer'''TRUE);

    echo $html;


_redirect_to_login_page method in core/Auth_controller.php is changed slightly:


PHP Code:
// No need to redirect to the login form if alternate login page
if( ! in_array$this->uri->uri_string(), config_item('allowed_pages_for_login') ) )
{
    // Redirect to the login form
    header(
        'Location: ' secure_site_urlLOGIN_PAGE '?redirect=' $redirect ),
        TRUE,
        302
    
);



setup_login_form method in core/Auth_controller.php is changed slightly:


PHP Code:
// Login URL may be an alternate
$login_urls config_item('allowed_pages_for_login');

foreach( 
$login_urls as $login_url )
{
    // Login URL is an alternate (not optional)
    if$this->uri->uri_string() == $login_url && ! $optional_login )
    {
        $view_data['login_url'] = secure_site_url$login_url );

        break;
    }
}

if( ! isset( 
$view_data['login_url'] ) )
{
    $view_data['login_url'] = secure_site_urlLOGIN_PAGE $redirect );



So because you already have your admin login form, you'll probably just need to change the methods in Auth_controller.php. I had never expected this kind of usage, and honestly it is a little strange for me to wrap my head around. I think it is better to use Community Auth as it was intended to be used, so such changes will probably not be put into Community Auth, unless other feedback shows that it is likely to be a feature that more people will want. I hope this helps you.
Reply
#38

Having a separate admin login page is very common, remember wordpress?
It has separate login page for the administrator.

But anyway thanks wiil try to follow your instruction.
Reply
#39

(11-29-2015, 02:43 AM)solidcodes Wrote: Having a separate admin login page is very common, remember wordpress?
It has separate login page for the administrator.

But anyway thanks wiil try to follow your instruction.

Having thought about it a little more, there might be another way to do what you want to do. I was thinking that it would be possible to define LOGIN_PAGE in the auth_constants.php hook dynamically, falling back on the standard login page.

It is funny that I've used WordPress a lot, and never noticed it had more than one login page. I'll have to check that out.
Reply
#40

It's fine we are only humans we make mistakes.
Is not it this is the purpose of versioning the software to fix, update and upgrade the features.

By the way I think I found a bug.
Yesterday the system community-auth works fine without any error.
But this morning It display this error message.

Code:
A PHP Error was encountered

Severity: Error

Message: Call to a member function delete() on null

Filename: models/Auth_model.php

Line Number: 175

Backtrace:

So how do I fix that?

thanks
Reply




Theme © iAndrew 2016 - Forum software by © MyBB