4 use CXGN
::DB
::Connection
;
6 use CXGN
::Page
::FormattingHelpers qw
| page_title_html
|;
7 use CXGN
::People
::Login
;
8 use CXGN
::People
::Person
;
12 my $page = CXGN
::Page
->new("solpeople create account", "Koni");
13 my $dbh = CXGN
::DB
::Connection
->new();
15 my $conf = SGN
::Config
->load();
17 if ($conf->{is_mirror
}) {
18 $page->message_page("This site is a mirror site and does not support adding users. Please go to the main site to create an account.");
22 my ($first_name, $last_name, $username, $password, $confirm_password, $email_address)
23 = $page->get_arguments(qw(first_name last_name username password confirm_password email_address));
27 # check password properties...
30 if (length($username) < 7) {
31 push @fail, "Username is too short. Username must be 7 or more characters";
33 # does user already exist?
35 my $existing_login = CXGN
::People
::Login
-> get_login
($dbh, $username);
37 if ($existing_login->get_username()) {
38 push @fail, "Username \"$username\" is already in use. Please pick a different username.";
42 if (length($password) < 7) {
43 push @fail, "Password is too short. Password must be 7 or more characters";
45 if ("$password" ne "$confirm_password") {
46 push @fail, "Password and confirm password do not match.";
48 if ($password eq $username) {
49 push @fail, "Password must not be the same as your username.";
51 if ($email_address !~ m/[^\@]+\@[^\@]+/) {
52 push @fail, "Email address is invalid.";
55 push @fail,"You must enter a first name or initial.";
58 push @fail,"You must enter a last name.";
63 #$page->message_page("Account could not be created ".(join " ", @fail));
65 &show_fail_reasons
(\
@fail, $page);
71 my $confirm_code = $page->tempname();
72 my $new_user = CXGN
::People
::Login
->new($dbh);
73 $new_user -> set_username
($username);
74 $new_user -> set_password
($password);
75 $new_user -> set_pending_email
($email_address);
76 $new_user -> set_confirm_code
($confirm_code);
77 $new_user -> set_disabled
('unconfirmed account');
80 #this is being added because the person object still uses two different objects, despite the fact that we've merged the tables
81 my $person_id=$new_user->get_sp_person_id();
82 my $new_person=CXGN
::People
::Person
->new($dbh,$person_id);
83 $new_person->set_first_name($first_name);
84 $new_person->set_last_name($last_name);
87 my $host = CGI
->new->server_name;
88 my $subject="[SGN] Email Address Confirmation Request";
89 my $body=<<END_HEREDOC;
91 Please do *NOT* reply to this message. The return address is not valid.
92 Use sgn-feedback\@solgenomics.net instead.
94 This message is sent to confirm the email addresss for community user
97 Please click (or cut and paste into your browser) the following link to
98 confirm your account and email address:
100 http://$host/solpeople/account-confirm.pl?username=$username&confirm=$confirm_code
107 CXGN::Contact::send_email($subject,$body,$email_address);
113 print page_title_html("Create new account");
117 <table summary
="" width
="80%" align
="center">
118 <tr
><td
><p
>Account was created with username
\"$username\". To
continue, you must confirm that SGN staff can reach you via email address
\"$email_address\". An email has been sent with a URL to confirm this address
. Please check your email
for this message
and use the
link to confirm your email address
.</p></td
></tr
>
119 <tr
><td
><br
/></td
></tr
>
131 print page_title_html
("Create new account");
137 <div class='boxbgcolor5'><b>Please note:</b></a><br />
142 <li><b>Before</b> creating a new account, please check if you <b>already have an account</b> using the <a href="/search/direct_search.pl?search=directory">directory search</a>. </li>
143 <li>A link will be emailed to you. Please click on it to activate the account.</li>
144 <li><b>All fields are required.</b></li>
147 <form name="submit_userdata" method="post" action="new-account.pl">
148 <table summary="" cellpadding="2" cellspacing="2" width="80%" align="center">
150 <tr><td colspan="2"><br /></td></tr>
151 <tr><td>First name</td><td><input type="text" name="first_name" size="40" value="" /></td></tr>
152 <tr><td>Last name</td><td><input type="text" name="last_name" size="40" value="" /></td></tr>
153 <tr><td>Username</td><td><input type="text" name="username" size="12" value="" /></td></tr>
154 <tr><td colspan="2" style="font-size: 80%">Username must be at least 7 characters long.</td></tr>
155 <tr><td>Password</td><td><input type="password" name="password" size="12" value="" /></td></tr>
156 <tr><td colspan="2" style="font-size: 80%">Password must be at least 7 characters long and different from your username.</td></tr>
157 <tr><td>Confirm Password</td><td><input type="password" name="confirm_password" size="12" value="" /></td></tr>
158 <tr><td colspan="2"><br /></td></tr>
159 <tr><td>Email Address</td><td><input type="text" name="email_address" size="40" value="" /></td></tr>
160 <tr><td colspan="2" style="font-size: 80%">An email will be sent to this address requiring you to confirm its receipt to activate your account.<br /><br /><br /></td></tr>
162 <tr><td><input type="reset" /></td><td align="right"><input type="submit" name="create_account" value="Create Account" /></td></tr>
174 sub show_fail_reasons {
175 my $fail_ref = shift;
179 foreach my $s (@$fail_ref) {
180 $fail_str .= "<li>$s</li>\n"
189 <table summary
="" width
="80%" align
="center">
191 <p
>Your account could
not be created
for the following reasons
</p
>
197 <p
>Please
use your browser
\'s back button to try again
.</p
>
199 <tr
><td
><br
/></td
></tr
>