Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 355683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:02:26+00:00 2026-05-12T12:02:26+00:00

I have a user model that requires the user to change their password every

  • 0

I have a user model that requires the user to change their password every three months. I need to somehow check to see if the user is logged in (we allow anonymous browsers on certain sections of the site) and if their password is expired, force them to enter a new one before they can do anything else.

The brute-force way of doing this would be to add a little bit of code to each and every action (except the ChangePassword action in Account). For example:

var authenticatedUser = GetAuthenticatedUser();
if (authenticatedUser != null && authenticatedUser.IsPasswordExpired)
    return RedirectToAction("Account", "ChangePassword");

Obviously that’s a horrible way to solve this problem but I’m not sure what the right way to do it is. Any ideas? I’m pretty sure that we’re going to have to add more user data checks like this in the future, so I’d really like to find a good solution to it now.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T12:02:27+00:00Added an answer on May 12, 2026 at 12:02 pm

    I do custom authentication in my base controller class (all my controllers derive from this). You can override the protected Controller.OnAuthorization method. Note that OnAuthorization gets called after the Controller.Initialize method, so if you put other custom logic in the Initialize method, just remember that this is called first.

        /// <summary>
        /// Called when authorization occurs.
        /// </summary>
        /// <param name="filterContext">Contains information about the current request and action.</param>
        protected override void OnAuthorization(AuthorizationContext filterContext)
        {
            // Do custom authentication here.
            Authenticate();
    
            base.OnAuthorization(filterContext);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a User model that :has_many other models like Documents, Videos, Posts
I have a data model that includes common columns like addedBy, editedby (user), addedDate,
For example, if I have a user model and I need to validate login
When we have anything that requires user input (Eg adding a product to a
I have a Scouts model that requires two actions in addition to the standard
I have a database that is stuck in single-user mode. I kill the process
I have a model Foo which have a ForeignKey to the User model. Later,
In my user model, I have an attribute called nickname and validates as such:
Suppose you have two models, User and City, joined by a third model CityPermission:
I have a database in single user mode and I am trying to drop

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.