[rt-users] registration page

Forrest Stanley fstanley at netburner.com
Mon Dec 2 17:24:08 EST 2002


At 10:57 AM 12/2/2002 -0800, Forrest Stanley wrote:
>Has anyone completed an online registration page for RT? This is my 
>current project and I was wondering if there was any example code out 
>there. I have already created all the basics, but I am stuck when all the 
>information is submitted. I have been trying to use the User->Create 
>method. I'll post some of my code if anyone has any ideas.
>thanks,
>-FS


I managed to hack out a registration page this morning. Keep in mind that 
this is undertested code, and may contain errors. I suggest you do your own 
testing and modifications before you try any of this. Also, if anyone see's 
any glaring mistakes, please point them out to me :)
-FS

Here's what I did:

/lib/RT/User.pm (around line 128)   <comment out ACL checks when creating a 
User (allow anyone to create user)>

         #Check the ACL
         #unless ($self->CurrentUserHasRight('AdminUsers')) {
         #       return (0, 'No permission to create users');
         # }

/WebRT/html/Elements/Login (around line 18) <add link to registration screen>

         - <TD ALIGN=RIGHT>Username:</TD><TD ALIGN=LEFT><input name=user 
value="<%$user%>"></TD></TR>
         + <TD ALIGN=RIGHT>Username:</TD><TD ALIGN=LEFT><input name=user 
value="<%$user%>"><font size="-1"> <a 
href="/NoAuth/registration.html">register</a></TD></TR>





----------------/WebRT/html/NoAuth/registration.html----------------
<& /Elements/Header, Title=>'Registration' &>
<& /Elements/ListActions, actions => \@results &>
<form method=post>

<TABLE WIDTH=100% BORDER=0>
<TR>
<b><a href="http://localhost">Return to Login Page</a></b>
<TD VALIGN=TOP ROWSPAN=2>
<& /Elements/TitleBoxStart, title => 'Identity' &>
<b>Username:</b> <input name="UserName"><BR>
<b>Email:</b> <input name="EmailAddress"><BR>
<b>Real Name:</b> <input name="RealName"><BR>
Nickname: <input name="NickName">
<BR>
Unix login: <input name="Gecos">
<BR>
Extra info: <textarea name="FreeformContactInfo"></TEXTAREA>
<& /Elements/TitleBoxEnd &>
</TD>
<TD VALIGN=TOP>
<& /Elements/TitleBoxStart, title => 'Access control' &>
<TABLE>
<TR>
<TD ALIGN=RIGHT>
<b>New Password:</b>
</TD>
<TD ALIGN=LEFT>
<input type=password name="NewPass1">
</TD>
</TR>
<TR><TD ALIGN=RIGHT>
<b>Retype Password:</b>
</TD>
<TD>
<input type=password name="NewPass2">
</TD>
</TR>
</TABLE>
<& /Elements/TitleBoxEnd &>
</TD>
<TR>
<TD VALIGN=TOP>
<& /Elements/TitleBoxStart, title => 'Location' &>
Organization: <input name="Organization">
<BR>
Address1: <input name="Address1">
<BR>
Address2: <input name="Address2">
<BR>
City: <input name="City">
State: <input name="State">
Zip: <input name="Zip">
<BR>
Country: <input name="Country">
<BR>

<& /Elements/TitleBoxEnd &>
</TD>
</TR>
<TR>
<TD COLSPAN=2 VALIGN=TOP>

<& /Elements/TitleBoxStart, title => 'Phone numbers' &>
Residence: <input name="HomePhone" size=13>
Work: <input name="WorkPhone" size=13>
Mobile: <input name="MobilePhone" size=13>
Pager: <input name="PagerPhone" size=13>
<& /Elements/TitleBoxEnd &>
<BR>
<BR>


</TD>
</TR>
</TABLE>
<& /Elements/Submit &>
</form>

<%INIT>
my @results;
if ($NewPass1) {
if ($NewPass1 ne $NewPass2) {
push (@results, "Passwords did not match.");
}
else {
$Password = $NewPass1;
}
}
my $user_obj = new RT::User($session{'CurrentUser'});
if ($UserName && $Password && $RealName && $EmailAddress) {
$Comments = "User created via Web Registration";
$Privileged = 1;
my ($status, $msg) =
$user_obj->Create( Name => $UserName,
Gecos => $Gecos,
Password => $Password,
EmailAddress => $EmailAddress,
Privileged => $Privileged,
Comments => $Comments,
Organization => $Organization,
RealName => $RealName,
NickName => $NickName,
HomePhone => $HomePhone,
WorkPhone => $WorkPhone,
MobilePhone => $MobilePhone,
PagerPhone => $PagerPhone,
Address1 => $Address1,
Address2 => $Address2,
City => $City,
State => $State,
Zip => $Zip,
Country => $Country,
FreeformContactInfo => $FreeformContactInfo,
);
push (@results, $msg);
}
else {
if (!$UserName) { push (@results, "Required Field: Username\n") };
if (!$RealName) { push (@results, "Required Field: Real Name\n") };
if (!$EmailAddress) { push (@results, "Required Field: Email\n") };
}
$session{'i'}++;
</%INIT>


<%ARGS>
$UserName => undef
$EmailAddress => undef
$FreeformContactInfo => undef
$Organization => undef
$RealName => undef
$NickName => undef
$Lang => undef
$Gecos => undef
$HomePhone => undef
$WorkPhone => undef
$MobilePhone => undef
$PagerPhone => undef
$Address1 => undef
$Address2 => undef
$City => undef
$State => undef
$Zip => undef
$Country => undef
$NewPass1 => undef
$NewPass2=> undef
$Password => undef
$Comments => undef
$Privileged => undef
</%ARGS>




More information about the rt-users mailing list