Типа я (zilogic) wrote in changelog,
Типа я
zilogic
changelog

[livejournal] r19720: LJSUP-8796: After adding comment the use...

Committer: amyshkin
LJSUP-8796: After adding comment the user must stay authorized under that account under which he initiated comments
U   trunk/cgi-bin/LJ/User.pm
Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2011-08-15 06:12:23 UTC (rev 19719)
+++ trunk/cgi-bin/LJ/User.pm	2011-08-15 06:25:06 UTC (rev 19720)
@@ -261,6 +261,31 @@
     return $synd;
 }
 
+# save current user id, so we can restore it later
+sub save_current {
+    my ( $u ) = @_;
+    my $remote = LJ::get_remote();
+    return 0 unless $remote;
+
+    $u->set_prop('lastloginid', $remote->id);
+    return 1;
+}
+
+# restore user from prop lastloginid
+sub restore {
+    my ($u) = @_;
+    my $userid = $u->prop('lastloginid');
+    return 0 unless $userid;
+
+    $u->set_prop('lastloginid', 0);
+
+    my $old = LJ::load_userid( $userid );
+    return 0 unless $u;
+
+    $old->make_login_session('long', 0);
+    return 1;
+}
+
 sub is_protected_username {
     my ($class, $username) = @_;
     foreach my $re (@LJ::PROTECTED_USERNAMES) {

Tags: livejournal, pm, zilogic
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments