Skip to content

Commit

Permalink
Implement #185 add custom avatar image to simple login.
Browse files Browse the repository at this point in the history
profile_image_url には48x48の画像URLを指定してください
設定ファイルに正規表現で許可するURLを記載してください
(記載無い場合は、pyazoが入ります)
  • Loading branch information
uzulla committed Nov 10, 2013
1 parent 5373b67 commit 8c36100
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion config.pl.sample
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ use strict;
auth_endpoint => { # endpoint => [ $module_name, $args, $description_for_client ]
'/login' => [
'Yancha::Auth::Simple' => {
name_field => 'nick'
name_field => 'nick',
allow_profile_image_url_regex => '^http://pyazo.hachiojipm.org/image/'
} => { description => 'Test!' },
],
'/login/basic' => [
Expand Down
9 changes: 8 additions & 1 deletion lib/Yancha/Auth/Simple.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use Encode;
sub build_psgi_endpoint {
my ( $self, $opt ) = @_;
my $name_field = $opt->{ 'name_field' } || 'nick';
my $allow_avatar_img_url_regex = $opt->{ 'allow_profile_image_url_regex' } || '^http://pyazo.hachiojipm.org/image/';

my $endpoint = $opt->{ endpoint };

# クライアント向け情報に入力欄名を設定する
Expand All @@ -40,10 +42,15 @@ sub build_psgi_endpoint {
return $res->finalize;
}

my $avatar_img_url = $req->parameters->{ 'profile_image_url' } || '';
if($avatar_img_url !~ m|$allow_avatar_img_url_regex|){
$avatar_img_url = '';
}

my $user = $self->set_user_into_storage( {
user_key => '-:' . $nick,
nickname => $nick,
profile_image_url => '',
profile_image_url => $avatar_img_url,
profile_url => '',
sns_data_cache => '',
} );
Expand Down

0 comments on commit 8c36100

Please sign in to comment.