# How to check password before changing it?

**URL:** <https://www.ruby-forum.com/t/how-to-check-password-before-changing-it/128678>\
**Category:** Rails\
**Created:** [February 10, 2008, 11:01am UTC](https://www.ruby-forum.com/t/how-to-check-password-before-changing-it/128678 "2008-02-10T11:01:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kamhei82](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a88e4f/32.png) [@kamhei82](https://www.ruby-forum.com/u/kamhei82)\
**Post date:** [February 10, 2008, 11:01am UTC](https://www.ruby-forum.com/t/how-to-check-password-before-changing-it/128678/1 "2008-02-10T11:01:45Z")

</div>

Hello,  
I’ve installed acts as authenticated plugin and I’m trying to change it  
a little bit. I’ve created form where I can change my password. There  
are 3 inputs: old pass, new and confirm new pass. In user model there  
is:

(…)  
attr\_accessor :password  
(…)  
validates\_presence\_of :password, :if =\>  
:password\_required?  
validates\_presence\_of :password\_confirmation, :if =\>  
:password\_required?  
validates\_length\_of :password, :within =\> 4…40, :if =\>  
:password\_required?  
validates\_confirmation\_of :password, :if =\>  
:password\_required?  
(…)

What should I do to check if old password is correct? Is it possible to  
use validates\_ do do it?

Cheers,  
Stan

---

<div class="post-metadata">

**Author:** ![kamhei82](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a88e4f/32.png) [@kamhei82](https://www.ruby-forum.com/u/kamhei82)\
**Post date:** [February 10, 2008, 11:22am UTC](https://www.ruby-forum.com/t/how-to-check-password-before-changing-it/128678/2 "2008-02-10T11:22:29Z")

</div>

if Digest::SHA1.hexdigest(params[:oldpassword] ==  
current\_user.crypted\_password

On Feb 10, 2008 8:31 PM, Stanley W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> validates\_presence\_of :password, :if =\>  
> use validates\_ do do it?
> 
> ## Cheers, Stan
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.
