install.sh: Don't fail on unset $cfg_webreporoot
[girocco.git] / cgi / reguser.cgi
blob8c01c1f2ab1c5be9f38f5bddaa0fdf633d96a104
1 #!/usr/bin/perl
2 # (c) Petr Baudis <pasky@suse.cz>
3 # GPLv2
5 use strict;
6 use warnings;
8 use lib ".";
9 use Girocco::CGI;
10 use Girocco::Config;
11 use Girocco::User;
12 use Girocco::Util;
14 my $gcgi = Girocco::CGI->new('User Registration');
15 my $cgi = $gcgi->cgi;
17 unless ($Girocco::Config::manage_users) {
18 print "<p>I don't manage users.</p>";
19 exit;
22 if ($cgi->param('mail')) {
23 print "<p>Go away, bot.</p>";
24 exit;
27 if ($cgi->param('name')) {
28 # submitted, let's see
29 # FIXME: racy, do a lock
30 my $name = $gcgi->wparam('name');
31 Girocco::User::valid_name($name)
32 and Girocco::User::does_exist($name)
33 and $gcgi->err("User with that name already exists.");
35 my $user = Girocco::User->ghost($name);
36 if ($user->cgi_fill($gcgi)) {
37 $user->conjure;
38 print <<EOT;
39 <p>User $name successfuly registered.</p>
40 <p>Project administrators can now <a href="editproj.cgi">assign you</a> to have a push access to their projects
41 (use project name as username, admin password as password).
42 (One user can have push access to multiple projects and multiple users can have push access to one project.)
43 </p>
44 <p>Congratulations, and have a lot of fun!</p>
45 EOT
46 exit;
50 print <<EOT;
51 <p>Here you can register a user.
52 You need to register a user so that it can be granted project(s) push access.</p>
53 <p>SSH is used for pushing (the <tt>ssh</tt> protocol), your SSH key authenticates you -
54 there is no password (though we recommend that your SSH key is password-protected; use <code>ssh-agent</code> to help your fingers).
55 You can find your public key in <tt>~/.ssh/id_rsa.pub</tt> or <tt>~/.ssh/id_dsa.pub</tt>.
56 If you do not have any yet, generate it using the <code>ssh-keygen</code> command.
57 You can paste multiple keys in the box below, each on a separate line. Paste each key <em>including</em> the <tt>ssh-</tt>whatever prefix and email-like postfix.</p>
58 <p>We won't bother to verify your email contact,
59 but fill in something sensible in your own interest
60 so that we can contact you or confirm your identity shall the need arise. We also need to send you an e-mail if you want to update your SSH keys later.</p>
61 $Girocco::Config::legalese
62 <form method="post">
63 <p>Login: <input type="text" name="name" /></p>
64 <p>Email: <input type="text" name="email" /></p>
65 <p>Public SSH key(s): <textarea name="keys" rows="5" cols="80"></textarea></p>
66 <p style="display:none">Anti-captcha (leave empty!): <input type="text" name="mail" /></p>
67 <p><input type="submit" name="y0" value="Register" /></p>
68 </form>
69 EOT