CodeIgniter Forums
Logout message using shield - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Logout message using shield (/showthread.php?tid=91416)



Logout message using shield - bgeneto - 08-06-2024

I've tried the following approaches in order to send a logout message to the login view while using CI4 Shield:
PHP Code:
auth()->logout();
session()->setFlashdata('message''This is a message!');
return 
redirect()->to('login'); 

Also:
PHP Code:
auth()->logout();
return 
redirect()->to('login')->with('message''This is a message'); 

But both didn't work. What is the standard procedure to do a logout while passing a logout message other than 'successLogout'?


RE: Logout message using shield - kenjis - 08-06-2024

Shield sets a logout message by default:
https://github.com/codeigniter4/shield/blob/223fbd9954732fd9ff8599348b3296936508e843/src/Controllers/LoginController.php#L99-L108


RE: Logout message using shield - bgeneto - 08-07-2024

(08-06-2024, 06:19 PM)kenjis Wrote: Shield sets a logout message by default:
https://github.com/codeigniter4/shield/blob/223fbd9954732fd9ff8599348b3296936508e843/src/Controllers/LoginController.php#L99-L108

Yeah! But is there (currently) any way to set another message other than 'successLogout'? If not I would like to propose this feature...


RE: Logout message using shield - kcs - 08-07-2024

The messages used by Shield are inside Shield's Language folder, I guess you can edit the one that is not fitting your needs there? Or customise the view for the logout to something you want (inside the Config/Auth.php file)?


RE: Logout message using shield - biker64 - 08-07-2024

I haven't tried it but can't you just extend the controller and override the default logout

https://shield.codeigniter.com/customization/extending_controllers/


RE: Logout message using shield - kenjis - 08-07-2024

Create app/Language/{locale}/Auth.php to change the default message for Auth.successLogout:

PHP Code:
<?php

declare(strict_types=1);

return [
    'successLogout' => 'ログアウトしました。',
]; 



RE: Logout message using shield - kenjis - 08-07-2024

Also, as you see, your code is correct and no problem.
So if you did't see your message, you did not run it properly.


RE: Logout message using shield - Renta Ardhana - 08-09-2024

How about custom routes? ? https://shield.codeigniter.com/customization/route_config/