advocacy:perl_reset_email
Differences
This shows you the differences between two versions of the page.
| advocacy:perl_reset_email [2008/02/25 14:13] – created erickson | advocacy:perl_reset_email [2022/02/10 13:34] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | < | ||
| + | __PACKAGE__-> | ||
| + | method => ' | ||
| + | api_name => ' | ||
| + | signature => { | ||
| + | desc => q/Reset a user's password and email the results to the user/, | ||
| + | params => [{desc => ' | ||
| + | return => {desc => q/Returns 1 on success, 0 on failure/, type => ' | ||
| + | } | ||
| + | ); | ||
| + | use Email:: | ||
| + | sub reset_password_by_email { | ||
| + | my($self, $conn, $username) = @_; | ||
| + | my $e = new_editor(xact=> | ||
| + | |||
| + | my $user = $e-> | ||
| + | or return 0; | ||
| + | return 0 unless $user-> | ||
| + | |||
| + | my $password =int(rand 10000); | ||
| + | $user-> | ||
| + | $e-> | ||
| + | |||
| + | my $sender = Email:: | ||
| + | [Host => ' | ||
| + | my $to_addr = $user-> | ||
| + | my $from_addr = ' | ||
| + | |||
| + | my $email = << | ||
| + | To: $to_addr | ||
| + | From: $from_addr | ||
| + | Subject: Password Verification | ||
| + | |||
| + | Your password has been reset to $password. | ||
| + | |||
| + | |||
| + | my $stat = $sender-> | ||
| + | if($stat and $stat-> | ||
| + | $e-> | ||
| + | return 1; | ||
| + | } | ||
| + | return 0; | ||
| + | } | ||
| + | </ | ||