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 6643121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:00:45+00:00 2026-05-26T00:00:45+00:00

In my rails 3.1 application, I want to create and expire random password for

  • 0

In my rails 3.1 application, I want to create and expire random password for users.I am using devise gem for that.Any plugin available for expiring password withing some duration?
Or else Please give me some logical advice to implement this feature.
Please consider me as a newbie.

  • 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-26T00:00:45+00:00Added an answer on May 26, 2026 at 12:00 am

    It sounds like you just want to expire the password once. If you’re looking to do it at regular intervals (e.g. every couple of months) or if you want to prevent users from re-using passwords, it gets more complicated.

    Taken from an app I’m working on:

    app/models/user.rb (assuming that’s what you name your model):

    def password_should_expire?
      # your logic goes here, remember it should return false after the password has been reset
    end
    

    app/controllers/application_controller.rb

    before_filter :check_password_expiry
    def check_password_expiry
      return if !current_user || ["sessions","passwords"].include?(controller_name)
      # do nothing if not logged in, or viewing an account-related page
      # otherwise you might lock them out completely without being able to change their password
      if current_user.password_should_expire?
        @expiring_user = current_user # save him for later
        @expiring_user.generate_reset_password_token! # this is a devise method
        sign_out(current_user) # log them out and force them to use the reset token to create a new password
        redirect_to edit_password_url(@expiring_user, :reset_password_token => @expiring_user.reset_password_token, :forced_reset => true)
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to suspend users in my Rails application. I am using Devise. I
I have a still pretty simple Rails application that I want to develop using
I'm working on a Rails application that's kind of like a blog. Users create
I want to create a public live chat application using rails 3. I found
In my Rails application I want to use the will_paginate gem to paginate on
I have a non-rails application that I want to use rails active-record migrations with.
I have a Rails application that works with mongodb. I want to deploy it
I'm using attachment_fu in a rails application to handle file uploads, and i want
I want to create my Rails application with MySQL, because I like it so
I want to create a new rails application and fire up the rails server

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.