watch: add 'watch' support
[girocco/ztw.git] / cgi / pwproj.cgi
blobad770dbd22be5bdc8faa09ee62d382a0acb1f857
1 #!/usr/bin/perl
2 # (c) Zachary T Welch <zw@superlucidity.net>
3 # (c) Petr Baudis <pasky@suse.cz>
4 # GPLv2
6 use strict;
7 use warnings;
9 use lib qw(/home/repo/repomgr/cgi);
10 use Git::RepoCGI;
12 my $repo = Git::RepoCGI->new('Forgotten Project Password');
13 my $name = $repo->sparam('name');
14 my $proj = $repo->load_project($name);
16 my $mail = $proj->{email};
18 if ($repo->sparam('y0')) {
19 # submitted
20 my $newpwd = genpwd();
22 my $domain = $repo->site_domain;
23 my $subject = "[$domain] New password for project $name";
24 open (M, '|-', 'mail', '-s', $subject, $mail)
25 or $repo->bye("Cannot spawn mail: $!");
26 print M <<EOT;
27 Hello,
29 Somebody requested the password for project '$name.git' to be reset.
31 This address has been listed as the contact address for the project,
32 so you are receiving the new password:
34 $newpwd
36 If you did not request the password to be reset, then we apologize.
37 In any event, you must now use this new password to change the settings
38 for the '$name.git' project.
40 If you would like to change your project password again, you can use
41 this quick link to edit the project page:
43 Quick-link to the edit project page:
45 http://$domain/m/editproj.cgi?name=$name
47 Have fun!
48 EOT
49 close M or $repo->bye("Sending mail to $mail for $name failed: $!");
51 $proj->update_password($newpwd);
53 print "<p>Project password has been reset. Have a nice day.</p>\n";
54 exit;
57 print <<EOT;
58 <p>If you have forgotten the admin password for the '$name' project,
59 it can be reset to a random string that will be mailed to the listed
60 contact e-mail address:&nbsp;<tt>&lt;$mail&gt;</tt>.</p>
61 <form method="post">
62 <input type="hidden" name="name" value="$name" />
63 <p><input type="submit" name="y0" value="Reset Password" /></p>
64 </form>
65 EOT