I need a solution where I can restrict the user to save any data when he is been deactivated by the admin. Suppose the user is active on a page where he is going to save a form but at the same instance admin has deactivated him. so , now when he try to save the form , he should be redirected to the login page saying "Your account is been deactivated, contact the support", without saving the data. I am working in cakephp 3.x . I tried to use beforeFilter for it. But it is deactivating the user but also the user is able to save the data.
How to restrict saving of data in db for user when the admin deactivated it in cakephp3.x?
35 Views Asked by Sumeet Mathew At
1
There are 1 best solutions below
Related Questions in AUTHORIZATION
- Protect Server Actions with Next Auth in Next JS 14
- Set-Cookie header not forwarded by nginx to the client
- System.InvalidOperationException: The AuthorizationPolicy named: 'Admin' was not found
- Missing render HTML element for login requests from client to server
- How to get different types of authentication in Thymeleaf
- https://accounts.google.com/gsi/client missing 'Access-Control-Allow-Origin' header
- Authorization error with Django on Windows with IIS
- Role based restriction in requestMatchers in Spring Security does not receive sent Authorization header
- How do I get my Python code to pass the authorization needed for it to connect to Notion
- Integrating Okta via a Authorization Filter
- Verify Token To Login In Firebase (Aauthorization)
- When hashing an API key, should I hash the suffix / prefix as well?
- How can I implement synchronous registration on a website and a forum by linking their databases?
- Need to addlocal repo authorization to existing yaml file
- dropbox api video share_url authorization error
Related Questions in CAKEPHP-3.X
- Cakephp 3 - Manual patch & save of associated data
- Display a msg when a user authenticates more than 5 times a day with cakephp 3.x or 4
- Cakephp 3 : How to insert data on db from a behavior
- Cakephp 3 Redirect when session expires
- Cakephp 3 ORM contain condition use field from parent table
- Cakephp Showing count of items by relationship
- Determine which tab is active from the controller
- How can I define a replicate behavior for the execute method without changing all the models' namespace?
- CAKEPHP 3: Like condion special character paginate
- cakePHP 3.0 nested associations
- Subquery in CakePhp with InnerJoin
- always getting error trying to elaborate sql query into cakephp; how to convert this one?
- CakePHP query: where condition with calculated fields
- Filter with association "BelongsTo" and "HasMany" with CakePHP
- Array Variable not updated after adding search condition in cakephp 3.437
Related Questions in BEFORE-FILTER
- Rails controller tests: "Filter chain halted" never appears
- Before filter, calling a method with param throws syntax error. Ruby
- filter methods in before_action after of another before_action
- rails before_action not in extended classes
- How to skip a before_filter in dev environment
- How to skip before filter in model with ruby on rails 5.2?
- How to restrict saving of data in db for user when the admin deactivated it in cakephp3.x?
- render/head in before_action does not stop executing the rest of the action
- CakePhp Can´t Redirect beforeFilter
- Using before_filter for accessing two model authentication
- How to use rails before_action conditional for only some actions?
- How to filter an object in rails so that only the user that created it or an admin can destroy that object?
- Restricting authorization to individual records instead of whole controller action in Rails
- How to use require_relative with an rspec test?
- Ruby on Rails - before_action with condition only when one attribute has been changed
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
I had a similar situation. I added a custom finder to the auth component to restrict deactivated users from making requests when they were deactivated but it only stopped deactivated users from logging in and NOT immediately restricting them from making any request. This meant a deactivated user could still access the application for the remainder of their session. (A lot of havoc can be caused by a disgruntled deactivated employee in say 10 hours.)
My solution was to tell the auth component to use controller hook methods for authorization. Cookbook info here
App Controller - Initialize action - Auth Component
And this is what logs the user out immediately
App Controller - isAuthorized
App Controller - checkActiveAndRole - (Streamlined for this post)
And this worked for me. Ie: Checking if the user is active on every request with the isAuthorized() function in the app controller