The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Automatic password suggestion for your Rails app

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jeremy Voorhis

Posts: 212
Nickname: jvoorhis
Registered: Oct, 2005

Jeremy Voorhis is a Rubyist in northeast Ohio.
Automatic password suggestion for your Rails app Posted: Apr 6, 2006 7:34 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Jeremy Voorhis.
Original Post: Automatic password suggestion for your Rails app
Feed Title: JVoorhis
Feed URL: http://feeds.feedburner.com/jvoorhis
Feed Description: JVoorhis is a Rubyist in northeast Ohio. He rambles about Ruby on Rails, development practices, other frameworks such as Django, and on other days he is just full of snark.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jeremy Voorhis
Latest Posts From JVoorhis

Advertisement

Note that this will only work on UNIX systems.

in app/helpers/admin/accounts_helper.rb:

module Admin::AccountsHelper
  def password_recommendation
    return "<p>Suggested password: <code>#{`apg`.split("\n").first}</code></p>" if use_apg?
  end

  # $ apg -v  
  # APG (Automated Password Generator)
  # version 2.2.3 (PRNG: X9.17/CAST)
  # Copyright (c) 1999, 2000, 2001, 2002, 2003 Adel I. Mirzazhanov
  def use_apg?
    `apg -v`.grep( /APG \(Automated Password Generator\)/ ) ? true : false
  end
end 
In app/views/admin/accounts/_form.rhtml:

  ...
  <h3><label for="user[password]">Password</label></h3>
  <div>
    <%= password_recommendation %>
    <%= password_field :user, :password %>
  </div>
  ...

If apg is available on your system, you should see something like the following in your form:

Suggested password: JidIlvEywr

Read: Automatic password suggestion for your Rails app

Topic: Upgrading Rails to Ruby 1.8.4 Previous Topic   Next Topic Topic: Tool support vs. simplicity

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use