Skip to content

Instantly share code, notes, and snippets.

@gtsafas
Created August 22, 2011 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gtsafas/28bd1f125e9b729937c3 to your computer and use it in GitHub Desktop.
Save gtsafas/28bd1f125e9b729937c3 to your computer and use it in GitHub Desktop.
validate helper
helper validateUser => sub {
my ($self,$username,$password) = @_;
#Fetch encrypted password from database
my $encrypted_password = $self->dbh->selectrow_array("SELECT password FROM users WHERE name=?",undef,$username);
#Check if we got any results
return 3 if !defined $encrypted_password;
#User exists lets validate the password
# valid / fail
return $self->bcrypt_validate( $password, $encrypted_password );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment