Redirecting all pages in laravel - laravel

Ok
So I have a simple page with not many functions as I have been working on the front end but I am now ready to start implementing features and the first feature I want to put in is where a certified admin could press a button on the page and it makes every page redirect to a page that says the site is in maintenance mode
Now I already have the Authentication sorted out for the admin and auth is used.
What could I do?

Create this route:
Route::get('/down', function(){
Artisan::call('down');
});
And then create a button in a view that leads to '/down'. Your website will turn to maintenance mode.
You might want to protect that route with a middleware. To go back to normal mode, you'll have to execute php artisan up in the terminal, since all the website will be frozen.

Related

Laravel Nova: The login form is in HTTP instead of HTTPS

Context
I've installed Laravel Nova, executed the migrations and created the Nova user by following the docs https://nova.laravel.com/docs/3.0/installation.html#installing-nova . Now I'm trying to login.
Expected behavior
When I send the login form, I'm redirected to the backoffice panel.
Actual behavior
When I send the login form, I'm redirected to a Chrome page "This page is not secured, are you sure you want to send your form data?" (approximately the English translation of the French displayed error :D ).
Clues
The login form is shown at this URL: "https://.../nova/login".
The login form, however, contains this action: "http://.../nova/login" - NB: so it's not HTTPS, but HTTP.
Question
Where could I set a Laravel and/or Nova config option to tell Nova to use https instead of http in the action of the login form Nova shows?
Since Nova doesn't seem to use any environment/configuration option to be able to choose the good HTTP/HTTPS protocol, I've directly written the following, in app/Providers/AppServiceProvider (NB: I don't really know the drawbacks of this solution so I don't recommend you to do it, even if in my case it worked well to fix this bug):
public function boot()
{
\URL::forceScheme('https');
}

How to redirect the user to another page after they have logged in with Ion Auth CodeIgniter

I have been working on admin panel of my project. I use Ion_Auth. I have a problem about redirecting after I have logged in on the system.
If I change default_controller as "auth", everything is okey and after I logged in, I have been redirecting to the user lists. But I have already a default_controller as "Home" and I don't want to change it as "Auth". If I change it as "Auth", login screen is shown first. If I use home as default_controller, when I have logged in on the system, Home page is shown instead of the page of user lists.
So I guess I need two default controllers one of them for my home page and also the other one for ion auth.
Any idea about the solution?
In auth.php change the redirection route if user log in. That would be line 67 I guess. You need to play with ion_auth to set it fits your (application) needs.
I like to make parent controller in application/core that has checking function in constructor. All controllers that requires login part should extend that sort of controller. Google for phil sturgeon extending of MY_Controller.php to see what am I talking about.

Drupal in Moodle sharing session

I have a Moodle site, in one of the Moodle pages I have an iFrame which contains a Drupal application. I want the Drupal application to see whether the user is logged in on Moodle, and if so show extra content.
However, I cannot access the session data from Moodle (especially information on the User) to in Drupal.
I tried two things:
If the iframe was a normal PHP page, I'd pass session_start(); on the top of the page in order for the session to persists, but I have no idea HOW to do that in Drupal.
And since they are on the same server, I tried accessing the config.php file in Moodle from a plain PHP file in the Drupal directory, and, as expect, I was able to get the variable. But as soon as I do this inside the Drupal application, a clash in function name between Moodle and Drupal threw an error.
The other option is to add a plugin in Moodle which sets a cookie on user login, a cookie that Drupal can get. But I'm really against this option since anyone can set a cookie and it persists. (There's no guarantee the user will click log-out)
I've never used/touched Moodle and Drupal until today. Can anyone help me figure out how to check whether a user is logged in on Moodle, from an iframe running a Drupal application?
A quick google gives the following moodle plugin that may be useful: https://moodle.org/mod/forum/discuss.php?d=208285
Looks like it allows single sign-on between the two, I've never used moodle before, but this may be a step in the right direction.

Removing login page from localhost

I'm using WAMPserver and Joomla as my CMS.
What I would like to know is, how to remove the login page on the localhost
because I already can access the login page from localhost/administrator
I've tried searching on google for the answer but didn't find any.
First of all Joomla backend and front end using different session,
like you can login two different users at the same time, one front end and other back end.
So when you remove front end login option you will lost the front end users entire facility.
Hope it make sense..

Session checks for loggedin user on pages / links?

When a user visits a page, does the system check if the user is loggedin on every page, with every link click or is this a one time thing? The issue I am having is: The user logsin which works fine. But if i enter the URL to my signup page the system directs me to the signup page and changes my header back to as if i am a non user. And this is happening randomly on many pages. Some places without signing in it is showing me the registered user's header. So i assume the session is not working but I am not sure how the system knows or checks this or if it is auto or do we need to write code for each page, each link on each page? Platform is codelignitor php.
Thanks.
I would think this depends on what language you are using for your pages. Some more details would be helpful here. The system may be using a cookie to check if you are still valid and this cookie is expiring.
I guess you are missing the session check codes. Please check the session set in every controller class so that if logged in session is not enable just redirect to general user page else to logged in user page.
Probably there are some controllers that are protected and some public. If you are using an Auth library probably there is a method like $this->auth->logged_in() or similar. Check it in the contrsuctor of each protected controller, or, better yet, make a protected_controller class that extends CI' base controller, that does the job. Then make protected controllers to use this as base.

Resources