Closed Lamineslot closed 1 year ago
Hello @Lamineslot,
It's an interesting idea, but I don't think soft-deleting a user is the best way to ban/block/remove users from your application. Soft deletes should act as a "trash bin" for your data, in case you delete something accidentally.
Blocking users is as simple as adding another field to the user's migration and verifying whether the user is blocked through a middleware.
Hi @JakyeRU,
I see. Would you be able to add that functionality to Larascord? This would allow you to check whether the user is blocked during the login process, which is standard practice and much easier than adding a middleware to each route.
You don't need to add a middleware to each route. You can add your middleware once in app\Http\Kernel.php
in the web
category. It will get executed on each request if the user is authenticated. You can check there whether the user is banned or not.
I am planning to add some action classes in the future to execute custom code and allow authentication dynamically.
I'll reopen this issue for now.
Soft-deleted users will now see the following error message:
You will have to republish your configuration or add the following error in config/larascord.php
otherwise a different error will appear.
'user_deleted' => [
'message' => 'Your account is deleted and you can\'t log in.',
'redirect' => '/'
]
You're awesome. Thanks a lot!
Is your feature request related to a problem? Please describe. In my project which uses Larascord, I'd like to soft delete users, to have a way to block/remove users from the application. Whenever I soft delete a user and the user logs in again, it doesn't look at existing eccounts which are soft deleted. Instead, it tries to create a new user, resulting in an integrity constraint violation.
Describe the solution you'd like It would be awesome if Larascord would check whether or not there's a user which has been soft deleted when creating a new user. Additionally, Larascord should provide an error message to the user when the account has been soft deleted, possibly making use of the success message 'user_deleted'.