omniauth-bungie-oauth2 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 902e8466e478598129f2cfaddf9be23a7c208ae9
4
- data.tar.gz: 3dd6a9d0b761309041f052b6d6a51019c37891e3
3
+ metadata.gz: c61ec53e71ca799b4ca1b7d81e660c2e66420af2
4
+ data.tar.gz: '080e78001f67eacdc86d5e606673f67c128b3eb9'
5
5
  SHA512:
6
- metadata.gz: d622358e21d6ea2cdc0c250cc78f0202f2ac399cd369baa4bc8e83d09b7cc31f28172001b09645ec8436d7745e706a60c5047a136b1301ef970647d3d096529a
7
- data.tar.gz: 6a8b7d04d85dfc5fd84e6d02705588337b8c911d7393a8925bb2e89e9c6a3a7826ae5fff625705a564af47927144da973b47d40259a4de971fb2bc24c30ba343
6
+ metadata.gz: e2523fa010311c7786fbfad35b4ca2d13f207c8e47023ae8d53e64b5f4ee609ce6f257fcb13c682258302b76364439ebe691819216dd705a3ad959d495c72539
7
+ data.tar.gz: e4781cfe6382f59ec9d9d77a8a7737ce928559850e4a657928fec2536f84eb0466063e7124a2b0fa2d0d9ce45ab908c071b562f097913b04d997303cbd605cab
data/.gitignore CHANGED
@@ -8,4 +8,6 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  .idea
11
- .gem
11
+ *.gem
12
+ .rspec
13
+ .tags
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Omniauth::Bungie::Oauth2
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/omniauth-bungie-oauth2.svg)](https://badge.fury.io/rb/omniauth-bungie-oauth2)
4
+ [![Build Status](https://travis-ci.org/RuBAN-GT/omniauth-bungie-oauth2.svg?branch=master)](https://travis-ci.org/RuBAN-GT/omniauth-bungie-oauth2)
5
+
3
6
  A Bungie OAuth2 strategy for Omniauth.
4
7
 
5
8
  ## Installation
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bungie_client"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -26,6 +26,13 @@ module OmniAuth
26
26
  end
27
27
  end
28
28
 
29
+ def merge_stack(stack)
30
+ stack.inject({}) do |a, e|
31
+ a.merge!(e) unless e.nil?
32
+ a
33
+ end
34
+ end
35
+
29
36
  # Updated callback phase with new refreshing
30
37
  def callback_phase
31
38
  error = request.params["error_reason"] || request.params["error"]
@@ -39,6 +46,7 @@ module OmniAuth
39
46
  self.access_token = access_token.refresh!(token_params) if access_token.expired?
40
47
 
41
48
  env['omniauth.auth'] = auth_hash
49
+
42
50
  call_app!
43
51
  end
44
52
  rescue ::OAuth2::Error, CallbackError => e
@@ -74,13 +82,22 @@ module OmniAuth
74
82
  # Get important data
75
83
  uid { raw_info.dig('bungieNetUser', 'membershipId') }
76
84
  info do
77
- destiny = raw_info['destinyAccounts']&.first
85
+ if raw_info['destinyAccounts'].any?
86
+ destiny = raw_info['destinyAccounts'].first
87
+ {
88
+ :membership_id => destiny.dig('userInfo', 'membershipId'),
89
+ :membership_type => destiny.dig('userInfo', 'membershipType'),
90
+ :display_name => destiny.dig('userInfo', 'displayName')
91
+ }
92
+ else
93
+ destiny = raw_info['bungieNetUser']
78
94
 
79
- {
80
- :membership_id => destiny.dig('userInfo', 'membershipId'),
81
- :membership_type => destiny.dig('userInfo', 'membershipType'),
82
- :display_name => destiny.dig('userInfo', 'displayName')
83
- } unless destiny.nil?
95
+ {
96
+ :membership_id => destiny['membershipId'],
97
+ :membership_type => 254,
98
+ :display_name => destiny['displayName']
99
+ }
100
+ end
84
101
  end
85
102
  extra do
86
103
  {
@@ -1,5 +1,5 @@
1
- module Omniauth
1
+ module OmniAuth
2
2
  module BungieOauth2
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
5
5
  end
@@ -5,7 +5,7 @@ require 'omniauth-bungie-oauth2/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'omniauth-bungie-oauth2'
8
- spec.version = Omniauth::BungieOauth2::VERSION
8
+ spec.version = OmniAuth::BungieOauth2::VERSION
9
9
  spec.authors = ['Dmitry Ruban']
10
10
  spec.email = ['dkruban@gmail.com']
11
11
 
@@ -15,6 +15,8 @@ Gem::Specification.new do |spec|
15
15
  spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files`.split("\n")
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
20
  spec.require_paths = ['lib']
19
21
 
20
22
  spec.add_development_dependency 'bundler', '~> 1.13'
@@ -1,12 +1,9 @@
1
1
  require 'spec_helper'
2
+ require 'omniauth-bungie-oauth2/version'
2
3
  require 'omniauth-bungie-oauth2'
3
4
 
4
- describe Omniauth::Strategies::Bungie do
5
+ describe OmniAuth::Strategies::Bungie do
5
6
  it "has a version number" do
6
- expect(Omniauth::BungieOauth2::VERSION).not_to be nil
7
- end
8
-
9
- it "does something useful" do
10
- expect(false).to eq(true)
7
+ expect(OmniAuth::BungieOauth2::VERSION).not_to be nil
11
8
  end
12
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-bungie-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Ruban
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-25 00:00:00.000000000 Z
11
+ date: 2017-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -155,6 +155,8 @@ files:
155
155
  - LICENSE.txt
156
156
  - README.md
157
157
  - Rakefile
158
+ - bin/console
159
+ - bin/setup
158
160
  - lib/oauth2/bungie_access_token.rb
159
161
  - lib/oauth2/bungie_client.rb
160
162
  - lib/omniauth-bungie-oauth2.rb