4 use CXGN
::DB
::Connection
;
6 use CXGN
::Page
::FormattingHelpers qw
| page_title_html
|;
7 use CXGN
::People
::Login
;
8 use CXGN
::People
::Person
;
11 use CatalystX
::GlobalContext
'$c';
13 my $page = CXGN
::Page
->new("solpeople create account", "Koni");
14 my $dbh = CXGN
::DB
::Connection
->new();
16 my $conf = $c->config;
18 if ($conf->{is_mirror
}) {
19 $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.");
23 my ($first_name, $last_name, $username, $password, $confirm_password, $email_address, $organization)
24 = $page->get_arguments(qw(first_name last_name username password confirm_password email_address organization));
28 # check password properties...
31 if (length($username) < 7) {
32 push @fail, "Username is too short. Username must be 7 or more characters";
34 # does user already exist?
36 my $existing_login = CXGN
::People
::Login
-> get_login
($dbh, $username);
38 if ($existing_login->get_username()) {
39 push @fail, "Username \"$username\" is already in use. Please pick a different username.";
43 if (length($password) < 7) {
44 push @fail, "Password is too short. Password must be 7 or more characters";
46 if ("$password" ne "$confirm_password") {
47 push @fail, "Password and confirm password do not match.";
51 push @fail, "'Organization' is required.'";
54 if ($password eq $username) {
55 push @fail, "Password must not be the same as your username.";
57 if ($email_address !~ m/[^\@]+\@[^\@]+/) {
58 push @fail, "Email address is invalid.";
61 push @fail,"You must enter a first name or initial.";
64 push @fail,"You must enter a last name.";
69 #$page->message_page("Account could not be created ".(join " ", @fail));
71 &show_fail_reasons
(\
@fail, $page);
77 my $confirm_code = $page->tempname();
78 my $new_user = CXGN
::People
::Login
->new($dbh);
79 $new_user -> set_username
($username);
80 $new_user -> set_password
($password);
81 $new_user -> set_pending_email
($email_address);
82 $new_user -> set_confirm_code
($confirm_code);
83 $new_user -> set_disabled
('unconfirmed account');
84 $new_user -> set_organization
($organization);
87 #this is being added because the person object still uses two different objects, despite the fact that we've merged the tables
88 my $person_id=$new_user->get_sp_person_id();
89 my $new_person=CXGN
::People
::Person
->new($dbh,$person_id);
90 $new_person->set_first_name($first_name);
91 $new_person->set_last_name($last_name);
94 my $host = CGI
->new->server_name;
95 my $subject="[SGN] Email Address Confirmation Request";
96 my $body=<<END_HEREDOC;
98 Please do *NOT* reply to this message. The return address is not valid.
99 Use sgn-feedback\@solgenomics.net instead.
101 This message is sent to confirm the email address for community user
104 Please click (or cut and paste into your browser) the following link to
105 confirm your account and email address:
107 http://$host/solpeople/account-confirm.pl?username=$username&confirm=$confirm_code
114 CXGN::Contact::send_email($subject,$body,$email_address);
120 print page_title_html("Create New Account");
124 <table summary
="" width
="80%" align
="center">
125 <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
>
126 <tr
><td
><br
/></td
></tr
>
138 print page_title_html
("Create New Account");
144 <div class='boxbgcolor5'><b>Please note:</b></a><br />
149 <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>
150 <li>A link will be emailed to you. Please click on it to activate the account.</li>
151 <li><b>All fields are required.</b></li>
155 <div class="container-fluid">
157 <div class="col-sm-2 col-md-2 col-lg-2">
159 <div class="col-sm-8 col-md-8 col-lg-8" >
160 <div class="panel panel-danger">
161 <div class="panel-heading">Notice</div>
162 <div class="panel-body">
164 <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>
165 <li>A link will be emailed to you. Please click on it to activate the account.</li>
166 <li><b>All fields are required.</b></li>
171 <form class="form-horizontal" role="form" name="submit_userdata" method="post" action="new-account.pl">
172 <div class="form-group">
173 <label class="col-sm-3 control-label">First Name: </label>
174 <div class="col-sm-9">
175 <input class="form-control" type="text" name="first_name" value="" />
178 <div class="form-group">
179 <label class="col-sm-3 control-label">Last Name: </label>
180 <div class="col-sm-9">
181 <input class="form-control" type="text" name="last_name" value="" />
184 <div class="form-group">
185 <label class="col-sm-3 control-label">Organization: </label>
186 <div class="col-sm-9">
187 <input class="form-control" type="text" name="organization" value="" />
190 <div class="form-group">
191 <label class="col-sm-3 control-label">Username: </label>
192 <div class="col-sm-9">
193 <input class="form-control" type="text" name="username" value="" /><br/>Username must be at least 7 characters long.
196 <div class="form-group">
197 <label class="col-sm-3 control-label">Password: </label>
198 <div class="col-sm-9">
199 <input class="form-control" type="password" name="password" value="" /><br/>Password must be at least 7 characters long and different from your username.
202 <div class="form-group">
203 <label class="col-sm-3 control-label">Confirm Password: </label>
204 <div class="col-sm-9">
205 <input class="form-control" type="password" name="confirm_password" value="" />
208 <div class="form-group">
209 <label class="col-sm-3 control-label">Email Address: </label>
210 <div class="col-sm-9">
211 <input class="form-control" type="text" name="email_address" value="" /><br/>An email will be sent to this address requiring you to confirm its receipt to activate your account.<br/>
215 <button class="btn btn-default" type="reset" >Reset</button>
216 <button class="btn btn-primary" type="submit" name="create_account" value="Create Account" >Create Account</button>
220 <div class="col-sm-2 col-md-2 col-lg-2">
227 <form name="submit_userdata" method="post" action="new-account.pl">
228 <table summary="" cellpadding="2" cellspacing="2" width="80%" align="center">
230 <tr><td colspan="2"><br /></td></tr>
231 <tr><td>First name</td><td><input type="text" name="first_name" size="40" value="" /></td></tr>
232 <tr><td>Last name</td><td><input type="text" name="last_name" size="40" value="" /></td></tr>
233 <tr><td>Organization</td><td><input type="text" name="organization" size="40" value="" /></td></tr>
234 <tr><td>Username</td><td><input type="text" name="username" size="12" value="" /></td></tr>
235 <tr><td colspan="2" style="font-size: 80%">Username must be at least 7 characters long.</td></tr>
236 <tr><td>Password</td><td><input type="password" name="password" size="12" value="" /></td></tr>
237 <tr><td colspan="2" style="font-size: 80%">Password must be at least 7 characters long and different from your username.</td></tr>
238 <tr><td>Confirm Password</td><td><input type="password" name="confirm_password" size="12" value="" /></td></tr>
239 <tr><td colspan="2"><br /></td></tr>
240 <tr><td>Email Address</td><td><input type="text" name="email_address" size="40" value="" /></td></tr>
241 <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>
243 <tr><td><input type="reset" /></td><td align="right"><input type="submit" name="create_account" value="Create Account" /></td></tr>
254 sub show_fail_reasons {
255 my $fail_ref = shift;
259 foreach my $s (@$fail_ref) {
260 $fail_str .= "<li>$s</li>\n"
269 <table summary
="" width
="80%" align
="center">
271 <p
>Your account could
not be created
for the following reasons
</p
>
277 <p
>Please
use your browser
\'s back button to try again
.</p
>
279 <tr
><td
><br
/></td
></tr
>