diff --git a/oa-more/lib/omniauth/strategies/draugiem.rb b/oa-more/lib/omniauth/strategies/draugiem.rb index 726f0b8df..6262efe74 100644 --- a/oa-more/lib/omniauth/strategies/draugiem.rb +++ b/oa-more/lib/omniauth/strategies/draugiem.rb @@ -47,8 +47,8 @@ def callback_phase if request.params['dr_auth_status'] == 'ok' && request.params['dr_auth_code'] response = RestClient.get('http://api.draugiem.lv/json/', { :params => draugiem_authorize_params(request.params['dr_auth_code']) }) auth = MultiJson.decode(response.to_s) - unless auth['error'] - @auth_data = auth + unless auth['error'] + @auth_data = auth super else fail!(auth['error']['code'].to_s,auth["error"]["description"].to_s) @@ -82,8 +82,8 @@ def get_user_info 'first_name' => user['name'], 'last_name' => user['surname'], 'location' => user['place'], - 'age' => user['age'], - 'adult' => user['adult'], + 'age' => user['age'] =~ /^0-9$/ ? user['age'] : nil, + 'adult' => user['adult'] == '1' ? true : false, 'image' => user['img'], 'sex' => user['sex'] } diff --git a/oa-more/spec/omniauth/strategies/draugiem_spec.rb b/oa-more/spec/omniauth/strategies/draugiem_spec.rb index ba4a8d526..e36f4ce9c 100644 --- a/oa-more/spec/omniauth/strategies/draugiem_spec.rb +++ b/oa-more/spec/omniauth/strategies/draugiem_spec.rb @@ -44,6 +44,8 @@ def strategy last_request.env['omniauth.auth']['credentials']['apikey'].should == "123456789" last_request.env['omniauth.auth']['user_info']['location'].should == "Durbe" + last_request.env['omniauth.auth']['user_info']['age'].should be_nil + last_request.env['omniauth.auth']['user_info']['adult'].should be_true end end end