Last active
August 29, 2015 14:27
-
-
Save adamtaylor/7560cdd1e7ed57910d19 to your computer and use it in GitHub Desktop.
Catalyst OAuth Controller Actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package MyApp::Controller::Root; | |
sub facebook_signup :Path('facebook_signup') :Args(0) { | |
my ($self, $c) = @_; | |
# Authenticate the user using the facebook realm | |
# Also ask for some extra permissions | |
if ( my $user = $c->authenticate( | |
{ scope => ['email','user_location'] }, | |
'facebook' | |
) ) { | |
$c->log->debug("authenticated"); | |
return $c->response->redirect( '/another-action' ); | |
} | |
else { | |
$c->log->debug("not authenticated"); | |
$c->detach; | |
} | |
} | |
sub strava_signup :Path('strava_signup') :Args(0) { | |
my ($self, $c) = @_; | |
# Authenticate the user using the strava realm | |
if ( my $user = $c->authenticate({}, 'strava') ) { | |
$c->log->debug("authenticated"); | |
return $c->response->redirect( '/another-action' ); | |
} | |
else { | |
$c->log->debug("not authenticated"); | |
$c->detach; | |
} | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment