• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to build an admin panel

#1
Hello guys, I've been wondering what is the right way to start the admin panel.

I mean I already have the admin pages, etc; but what I want is to block the access to the public, is there a way to do it by htaccess, or can you explain me how to do some type of login. 

And I think is going to be little bit hard, because as stated above all admin pages are done, but I never though of dong a login panel before accessing to it. 

Here is my controller (Admin/ index function):
PHP Code:
public function index(){
        
    
$data['title'] = 'Admin Panel';
    
$data['blog'] = $this->blog_model->get_blog();
    
$data['portfolio'] = $this->portfolio_model->get_portfolio();


 
       $this->load->view('templates/head'$data);
    
$this->load->view('templates/navbar'$data);
 
       $this->load->view('admin/dashboard',$data);
 
       $this->load->view('templates/footer'$data);
 
       

that's all what I got, I did not even create an admin model, or anything related to it.Neither a table in the databse.)

This is my dashboard:
[Image: 7b2d7ac45e0abdc28057cd7997d79ee2.jpg]

As I said the dashboard is completely done, with all the functions working, I just need to block the access
I do Front-End development most of the time, but I trying to get more into being a full-stack developer, so I'm now learning alll what I need to do!  Smile 
Reply

#2
Hey,

there are several login tutorials available. Just search for e. g. codeigniter 3 login tutorial and you will find a bunch of nice descriptions how to realize a login for your page.

With these basics you are able to wrap up your admin sites into a closed area.

The easiest way is to set some $_SESSION data like "login = TRUE" after the login was successfull.
Then you implement a check in every controller within your admin area, if user is logged in and has access to this controller. If not, redirect him to login page.

I hope this will help you ;-)

Best regards from Germany
Reply

#3
The best and easiest permission class I found was:

https://github.com/bcit-ci/CodeIgniter/w...sion-Class

Which I've integrated into ignited cms and ignited cms pro.
IgnitedCMS Pro
IgnitedCMS
Practical guide to IgnitedCMS - Book coming soon
Reply

#4
Try Ion_auth. It's quite basic and does the job well.
Reply

#5
Well this is what I got so far, I do nt want to create another views,etc. I just wat to block all the IP address, or set one Io to have the accesss to these pages. And to do that I put this in my __construct

       public function __construct()
       {
               parent::__construct();
$this->load->model('about_model');
$this->load->model('blog_model');
$this->load->model('categorias_model');
$this->load->model('cookies_model');
$this->load->model('news_model');
$this->load->model('portfolio_model');
$this->load->model('privacy_model');
$this->load->model('terms_model');
$this->load->model('skills_model');
$this->load->model('profesion_model');
$this->load->model('slider_model');
$this->load->library('pagination');


//// Block access to admin pages ////

           //Here you check ip allowed or not
           if (!in_array($this->input->ip_address(), array('107.208.103.39','2602:306:bd06:7270:fcdd:74c5:c591:dc4')))
           {
              // Either show 404
              show_404();

              // OR redirect somewhere else
              redirect('admin');
           }


       }

I found ths tutorial on Stackoverflow, byt apprently I have to create an input as called "ip_address" and I do not know where should I create it, but as I said before I would like to avoid the creating of new controller, views/models etc.
I do Front-End development most of the time, but I trying to get more into being a full-stack developer, so I'm now learning alll what I need to do!  Smile 
Reply

#6
"I do Front-End development most of the time, but I trying to get more into being a full-stack developer, so I'm now learning all what I need to do!"

"I just want to do this..., I want to avoid that..." - Why do you waste people's time? Just do what you intend to do.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.