+# Generate a session to use after successful login.
+sub getsession ($) {
+ my $email=shift;
+
+ IkiWiki::lockwiki();
+ IkiWiki::loadindex();
+ my $session=IkiWiki::cgi_getsession();
+
+ my $postsignin=IkiWiki::userinfo_get($email, "emailauthpostsignin");
+ IkiWiki::userinfo_set($email, "emailauthpostsignin", "");
+ if (defined $postsignin && length $postsignin) {
+ $session->param(postsignin => $postsignin);
+ }
+
+ $session->param(name => $email);
+ my $nickname=$email;
+ $nickname=~s/@.*//;
+ $session->param(nickname => Encode::decode_utf8($nickname));
+
+ IkiWiki::cgi_savesession($session);
+
+ return $session;
+}
+