[Rt-commit] r3554 - in RT-Authen-Bitcard: .
html/Callbacks/Bitcard/autohandler
kevinr at bestpractical.com
kevinr at bestpractical.com
Thu Jul 28 20:37:23 EDT 2005
Author: kevinr
Date: Thu Jul 28 20:37:21 2005
New Revision: 3554
Modified:
RT-Authen-Bitcard/ (props changed)
RT-Authen-Bitcard/html/Callbacks/Bitcard/autohandler/Auth
Log:
r6717 at SAD-GIRL-IN-SNOW: kevinr | 2005-07-28 19:37:42 -0400
* Added create-new-user functionality
Modified: RT-Authen-Bitcard/html/Callbacks/Bitcard/autohandler/Auth
==============================================================================
--- RT-Authen-Bitcard/html/Callbacks/Bitcard/autohandler/Auth (original)
+++ RT-Authen-Bitcard/html/Callbacks/Bitcard/autohandler/Auth Thu Jul 28 20:37:21 2005
@@ -4,16 +4,41 @@
$bc->token('6440e194b0ee0af1d4baec0570e496');
my $user = $bc->verify(\%ARGS);
- if ($user) {
- print "Verified user ". $user->{'email'}. '<br />';
- $session{'CurrentUser'} = RT::CurrentUser->new();
- $session{'CurrentUser'}->LoadByEmail( $user->{'email'} );
- if ( $session{'CurrentUser'}->id ) {
- print "Loaded user ". ( $session{'CurrentUser'} )->id;
- } else {
- print "Couldn't load user";
- }
- } else {
- print "Could not verify user";
- }
+ print "Could not verify user" unless ($user) || ( $session{'CurrentUser'} );
+
+ # if the user isn't logged in and we got credentials from Bitcard, load them
+ if (! $session{'CurrentUser'}) && ($user) {
+
+ print "Verified user ". $user->{'email'}. '<br />';
+
+ # Bitcard has verified that the user has control of this e-mail address,
+ # so it's okay to use it to get a valid RT user
+
+ # we've got a valid user, so try to load
+ $session{'CurrentUser'} = RT::CurrentUser->new();
+ $session{'CurrentUser'}->LoadByEmail( $user->{'email'} );
+ if ( $session{'CurrentUser'}->id ) {
+ print "Loaded user ". ( $session{'CurrentUser'} )->id;
+ }
+ else {
+ print "Couldn't load user; trying to create...";
+ $session{'CurrentUser'}->Create(
+ Name => $user->{'username'},
+ RealName => $user->{'name'},
+ EmailAddress => $user->{'email'},
+ );
+ if ( $session{'CurrentUser'}->id ) {
+ # redirect the user to their preference page to add more info
+ $m->redirect('User/Prefs.html');
+ }
+ else {
+ # we couldn't create the user. abort abort abort!
+ delete $session{'CurrentUser'};
+ $m->abort() unless $RT::WebFallbackToInternalAuth;
+ $m->comp('/Elements/Login', %ARGS,
+ Error => loc('Cannot create user: [_1]', $msg)
+ );
+ }
+ }
+ }
</%INIT>
More information about the Rt-commit
mailing list