Welcome Guest, Not a member yet? Register   Sign In
how to block app access without login
#1

(This post was last modified: 04-22-2022, 01:12 AM by Ahmed Haroon.)

is there a way to prevent users to access any url " except login and sign up "
as we can use App\Config\Filters.php as below (per my CI 4 course video till this question), it is a specific url to block and i can mention here in array multiples entries to block but is there a way to block all except above mentioned easy way (do not want to enter all one by one in the below list - if possible).
may be, my questions irritate but as metnioned i am very new to CI and my previous experience is not for a real web application development like CodeIgniter, so please, pardon me.


Code:
public $filters = [
        'login' => ['before' => ['/tasks(/*)?']]
    ];


regards
Reply
#2

(This post was last modified: 04-22-2022, 01:52 AM by luckmoshy.)

(04-22-2022, 01:11 AM)Ahmed Haroon Wrote: is there a way to prevent users to access any url " except login and sign up "
as we can use App\Config\Filters.php as below (per my CI 4 course video till this question), it is a specific url to block and i can mention here in array multiples entries to block but is there a way to block all except above mentioned easy way (do not want to enter all one by one in the below list - if possible).
may be, my questions irritate but as metnioned i am very new to CI and my previous experience is not for a real web application development like CodeIgniter, so please, pardon me.


Code:
public $filters = [
        'login' => ['before' => ['/tasks(/*)?']]
    ];


regards

can you please read here carefully
https://codeigniter.com/user_guide/incom...ght=filter
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals

Reply
#3

thanks @luckmoshy for great help.

Quote:There are times where you want to apply a filter to almost every request, but have a few that should be left alone. One common example is if you need to exclude a few URI’s from the CSRF protection filter to allow requests from third-party websites to hit one or two specific URI’s, while keeping the rest of them protected. To do this, add an array with the ‘except’ key and a URI to match as the value alongside the alias:
Code:
public $globals = [
    'before' => [
        'csrf' => ['except' => 'api/*'],
    ],
    'after' => [],
];

regards
Newbie here in CodeIgniter World !! Please appologize if any nonsense from me.  
environment: Windows 10, XAMPP 3.3.0, VS Code, SQLyog Community Ed. 
Reply
#4

(This post was last modified: 04-22-2022, 08:18 AM by luckmoshy.)

[quote="Ahmed Haroon" pid="395687" dateline="1650622914"]
thanks @luckmoshy for great help.

[quote]
There are times where you want to apply a filter to almost every request, but have a few that should be left alone. One common example is if you need to exclude a few URI’s from the CSRF protection filter to allow requests from third-party websites to hit one or two specific URI’s, while keeping the rest of them protected. To do this, add an array with the ‘except’ key and a URI to match as the value alongside the alias:
[/quote]
Code:
public $globals = [
    'before' => [
        'csrf' => ['except' => 'api/*'],
    ],
    'after' => [],
];

regards


[/php]




PHP Code:
public $aliases = [
    
'csrf' => \CodeIgniter\Filters\CSRF::class,
];

[
PHP]
public 
$globals = [
    
'before' => [
        
'csrf' => ['except' => ['foo/*''bar/*']],
    ],
    
'after' => [],
];


public 
filters = [
    
'foo' => ['before' => ['admin/*'], 'after' => ['users/*']],
    
'bar' => ['before' => ['api/*''admin/*']],
]; 

otherwise, if you are a newbie I will direct a nice tutorial

https://onlinewebtutorblog.com/work-with...-tutorial/
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals

Reply




Theme © iAndrew 2016 - Forum software by © MyBB