Welcome Guest, Not a member yet? Register   Sign In
Logout message using shield
#1

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'?
Reply
#2

Shield sets a logout message by default:
https://github.com/codeigniter4/shield/b...p#L99-L108
Reply
#3

(08-06-2024, 06:19 PM)kenjis Wrote: Shield sets a logout message by default:
https://github.com/codeigniter4/shield/b...p#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...
Reply
#4

(This post was last modified: 08-07-2024, 10:40 AM by kcs.)

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)?
Reply
#5

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

https://shield.codeigniter.com/customiza...ntrollers/
Reply
#6

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

PHP Code:
<?php

declare(strict_types=1);

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

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.
Reply
#8

How about custom routes? ? https://shield.codeigniter.com/customiza...te_config/
Reply




Theme © iAndrew 2016 - Forum software by © MyBB