Skip to content

Instantly share code, notes, and snippets.

@adamtaylor
Last active August 29, 2015 14:27
Show Gist options
  • Save adamtaylor/7560cdd1e7ed57910d19 to your computer and use it in GitHub Desktop.
Save adamtaylor/7560cdd1e7ed57910d19 to your computer and use it in GitHub Desktop.
Catalyst OAuth Controller Actions
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