<%args> $tab $id <%perl> use Masterkey::Admin; $m->comp("/mc/setup.mc"); my $user = $m->comp("/mc/utils/user.mc"); if (!defined $user) { print "How did you get here when you're not logged on?\n"; return; } # We need the identityId of the user we're trying to login as, so that # new_with_session() can look at the right cookie. my $destAdmin = new Masterkey::Admin($tab); my $destUser = $destAdmin->authTorus()->user1(id => $id) or die "can't find user $id"; my $destIdId = $destUser->field("identityId"); warn "trying to act as identityId '$destIdId'"; my(undef, $session, $newUser) = new_with_session Masterkey::Admin($tab, $r, 0, $destIdId, $id); my $url; if ($ENV{MAnewurls}) { my $realm = $newUser->field("identityId"); die "impossible identityId mismatch '$realm' != '$destIdId'" if $realm ne $destIdId; $url = "../../$realm/$tab/"; } else { $url = "../$tab/"; } # ### We should have code here to handle authUserCookie, but we know # it won't arise because the tabs that you log into using "act # as" don't have that setting. <& /mc/redirect.html, url => $url &>