[ic] Change Login

Russ Mann interchange-users@interchange.redhat.com
Tue Jan 29 12:31:59 2002


I have made this happen:  IC developers take note, you might want to add
this to the demo code.  I instruct users to use their email address for a
username, so some of the variables will be a bit confusing, possibly, like
"$login_email".

changelogin.html
------------------------------------------
[comment]
ui_template: Yes
ui_template_name: leftonly
[/comment]

[set component_after][/set]
[set members_only]1[/set]
[set page_banner]Shipping Addresses[/set]
[set component_hsize]3[/set]
[set hbanner][/set]
[set component_before][/set]
[set hpromo_type]specials[/set]
[set page_title]__COMPANY__ - Change Login Email[/set]
@_LEFTONLY_TOP_@

<!-- BEGIN CONTENT -->
<hr noshade color="#000000">
<center><font face="Arial" size="4">Change Login Email</font></center>
<hr noshade color="#000000">
<p align="left">
This form is used to change your login email address.  There are some
reasons to do
this, and some reasons not to.  Someone should explain those.
<br>
Your current login email address is: <b>[data session username]</b>.
<br>
<form action="[process-target]" method="post">
<input type="hidden" name="mv_todo" value="return">
<input type="hidden" name="mv_nextpage" value="changelogindone">
<table width="450" border="1" cellspacing="0" cellpadding="3"
bordercolor="#000000">
<tr><td align="right">
<b><font __FFACE__ size="1">New Login Email Address</font></b>
</td><td>
<input type="text" name="login_email" value="[data session username]"
size="40">
</td></tr>
</table>
<p>
<input type="submit" value="Change Login Email Address">
</form>

<!-- END CONTENT -->

@_LEFTONLY_BOTTOM_@
------------------------------------------

changelogindone.html
------------------------------------------
[comment]
ui_template: Yes
ui_template_name: leftonly
[/comment]
[set page_title]__COMPANY__ - Login Email Changed[/set]
[set page_banner]Shipping Address Added[/set]
@_LEFTONLY_TOP_@

<!-- BEGIN CONTENT -->
<hr noshade color="#000000">
<center><font face="Arial" size="4">Change Login Email</font></center>
<hr noshade color="#000000">
<p align="left">
[flag type=write tables="userdb ship_addresses transactions orderline
email_login_changes"]
[perl tables="userdb ship_addresses transactions orderline
email_login_changes"]
my $change_log_table = "email_login_changes";
my @tables = (
		"userdb",
		"ship_addresses",
		"transactions",
		"orderline"
		);
my $sql_req = '';
$login_email = "$Values->{login_email}";
$old_username = "$Session->{username}";

if ($login_email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
  $login_email !~
/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/)
{
$Scratch->{'update_ok'} = 0;
return "<b>$login_email</b> is not a valid email address.  No update
possible.";
}
if ($login_email eq $old_username) {
$Scratch->{'update_ok'} = 0;
return <<EOP;
<b>$login_email</b> is the same as <b>$old_username</b>.  No update
possible.
EOP
}
if ($Db{userdb}->record_exists($login_email)) {
$Scratch->{'update_ok'} = 0;
return <<EOP;
<b>$login_email</b> is already in use.  If you have more than one account
with us,
please email <a href="[area help/contact]"><b>Customer Service</b></a> to
get this resolved.
EOP
}

foreach $table(@tables) {
$sql_req = "UPDATE $table SET username = '$login_email' WHERE username =
'$old_username'";
$Db{$table}->query("$sql_req");
}
$Scratch->{'update_ok'} = 1;
$sql_insert = "INSERT INTO $change_log_table SET old_email_login =
'$old_username', new_email_login = '$login_email'";
$Db{$change_log_table}->query("$sql_insert");

return <<EOP;
Your login email address has been changed to <b>$login_email</b>.  You will
need to
<a href="[area login]"><b>Login</b></a> again with your new address.
EOP
[/perl]

[if scratch update_ok]
<!--
[userdb logout]
-->
[else]
<p>
<a href="[area changelogin]"><font size="2"><b><font
__FFACE__>BACK</font></b></font></a>
</p>
[/else]
[/if]
<!-- END CONTENT -->
@_LEFTONLY_BOTTOM_@
------------------------------------------


Here is the database structure for email_login_changes, where I log all the
changes in order to make sure I can backtrack any possible problems.
CREATE TABLE email_login_changes (
  code int(11) NOT NULL auto_increment,
  old_email_login varchar(255) NOT NULL default '',
  new_email_login varchar(255) NOT NULL default '',
  timestamp timestamp(14) NOT NULL,
  PRIMARY KEY  (code),
  UNIQUE KEY code (code),
  KEY code_2 (code)
) TYPE=MyISAM;

Please let me know if this is useful, and/or if this is modified for better
use.  If someone has a better way to do this, I'd like to see it!

Thanks,

Russ Mann


-----Original Message-----
From: interchange-users-admin@interchange.redhat.com
[mailto:interchange-users-admin@interchange.redhat.com]On Behalf Of
robert smith
Sent: Tuesday, January 29, 2002 9:55 AM
To: interchange-users@interchange.redhat.com
Subject: [ic] Change Login


Hi everyone!

We would like to allow users to change their login names. Is there any
way to do this through the userdb functions?
If not has anyone bypassed Interchange and done this at the database
level?

Regards,

Chaim Klar

_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail.
http://www.hotmail.com

_______________________________________________
interchange-users mailing list
interchange-users@interchange.redhat.com
http://interchange.redhat.com/mailman/listinfo/interchange-users