Displaying the required page when trying to login if the account was deleted by the admin #217
-
Hi! I am in the process of implementing deleting user accounts, so that the admin on the panel can close any account, I used the RodauthApp.rodauth.close_account(account_login: resource_account.email) and it works, but I want the deleted users to get html code that their account was closed by the administrator when they try to log in, so that the user can understand at once what is going on and why he can't log in. but the problem is that when trying to login a closed account rodauth just tries to find an active account with the desired login and writes that the account does not exist, this behavior does not suit me, is there a theoretical possibility in this situation to change the behavior to what I need, it is difficult to understand where to start? At the same time such a user can register a new account with the same mail but without the status of deleted by the admin user |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
You could use the before_login_route do
unless Account.closed.where(email: param(login_param)).empty?
return_response view("account_closed", "Account closed by admin")
end
end This relies on there being a You can also create a custom controller action that renders this page and redirect to it, e.g. |
Beta Was this translation helpful? Give feedback.
-
This construction seems to work, but I would like to additionally check that the user has entered the correct password to be sure that the author himself is trying to log in, can this be done in the current code implementation? |
Beta Was this translation helpful? Give feedback.
That's not going to automatically work, because you'd have to use
password_match?
, which relies on@account
being loaded into the Rodauth instance. That's normally done byaccount_from_login
, but we were skipping it here.Maybe try the following approach: