[Bps-public-commit] jifty-plugin-authentication-twitter branch, master, updated. 4650d08e3b5a267624b3b9293999570498d70dc3

Shawn Moore sartak at bestpractical.com
Thu Jun 3 03:27:26 EDT 2010


The branch, master has been updated
       via  4650d08e3b5a267624b3b9293999570498d70dc3 (commit)
      from  7ad7839d148583454f9d2abc2c811dddf41cd23a (commit)

Summary of changes:
 .../Twitter/Action/LinkTwitterUser.pm              |   60 ++++++++++++++++++++
 1 files changed, 60 insertions(+), 0 deletions(-)
 create mode 100644 lib/Jifty/Plugin/Authentication/Twitter/Action/LinkTwitterUser.pm

- Log -----------------------------------------------------------------
commit 4650d08e3b5a267624b3b9293999570498d70dc3
Author: Shawn M Moore <sartak at gmail.com>
Date:   Thu Jun 3 03:28:11 2010 -0400

    First cut of LinkTwitterUser

diff --git a/lib/Jifty/Plugin/Authentication/Twitter/Action/LinkTwitterUser.pm b/lib/Jifty/Plugin/Authentication/Twitter/Action/LinkTwitterUser.pm
new file mode 100644
index 0000000..4845d71
--- /dev/null
+++ b/lib/Jifty/Plugin/Authentication/Twitter/Action/LinkTwitterUser.pm
@@ -0,0 +1,60 @@
+use warnings;
+use strict;
+
+=head1 NAME
+
+Jifty::Plugin::Authentication::Twitter::Action::LinkTwitterUser - link Twitter user to current user
+
+=cut
+
+package Jifty::Plugin::Authentication::Twitter::Action::LinkTwitterUser;
+use base qw/Jifty::Action/;
+
+=head1 ARGUMENTS
+
+=cut
+
+use Jifty::Param::Schema;
+use Jifty::Action schema {
+};
+
+=head1 METHODS
+
+=head2 take_action
+
+Get the session key using the Twitter API.  Link to current user.
+
+=cut
+
+sub take_action {
+    my $self     = shift;
+
+    if ( not Jifty->web->current_user->id ) {
+        $self->result->error(_("You must be logged in to link your user to your Twitter account."));
+        return;
+    }
+
+    my $user = Jifty->web->current_user->user_object;
+
+    my $name = 'xxx';
+
+    # Set data
+    $user->__set( column => 'twitter_name', value => $name );
+
+    # Success!
+    $self->report_success;
+
+    return 1;
+}
+
+=head2 report_success
+
+=cut
+
+sub report_success {
+    my $self = shift;
+    $self->result->message(_("Your account has been successfully linked to your Twitter user %1!", Jifty->web->current_user->user_object->twitter_name ));
+}
+
+1;
+

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list