simple_mobile_oauth 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/simple_mobile_oauth/authenticator.rb +19 -19
 - data/lib/simple_mobile_oauth/identifiable.rb +0 -14
 - data/lib/simple_mobile_oauth/version.rb +1 -1
 - data/test/dummy/log/test.log +36 -0
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 186a40edb7005d3736a7ccbfe597b115a349feca
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: cae2e253cb2032529efa4bcfb82127133b06239e
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 2441e0114f7a625a63c9c7baa3dd21bd4d9eac1dd76f2211337122383630d1f477bda0f4965bd9235fae971b4c9b5c4af8ee51622739f0e192a753dbd016ef3b
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 0e4f3b0e9aadefedbc445e30e75ce795ac9e028e115d28bdcbd56680cc95c075176785d7ff4e2b6101ad31b8c4a7664a09de344316b951b218ba3bf2fa7e08c3
         
     | 
| 
         @@ -90,33 +90,33 @@ module SimpleMobileOauth 
     | 
|
| 
       90 
90 
     | 
    
         
             
                    user = _find_user_strategy(user_params)
         
     | 
| 
       91 
91 
     | 
    
         
             
                    raise InvalidParamsError, 'could not find user from params given' unless user
         
     | 
| 
       92 
92 
     | 
    
         
             
                    raise IdentityAlreadyBoundError, 'oauth identity exists with another user' \
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
      
 93 
     | 
    
         
            +
                      if identity_already_bound_to_different_user?(identity_owner, user)
         
     | 
| 
       94 
94 
     | 
    
         | 
| 
       95 
95 
     | 
    
         
             
                      # So the identity owner and user found from param match
         
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
      
 96 
     | 
    
         
            +
                    user
         
     | 
| 
      
 97 
     | 
    
         
            +
                  else
         
     | 
| 
      
 98 
     | 
    
         
            +
                    raise InvalidParamsError, 'missing user params' unless user_params
         
     | 
| 
       99 
99 
     | 
    
         | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
      
 100 
     | 
    
         
            +
                    user = _find_user_strategy(user_params) || _build_user_strategy(user_params)
         
     | 
| 
       101 
101 
     | 
    
         | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
                    end
         
     | 
| 
      
 102 
     | 
    
         
            +
                    user.identities.build(identity_params)
         
     | 
| 
      
 103 
     | 
    
         
            +
                    user.save
         
     | 
| 
      
 104 
     | 
    
         
            +
                    user
         
     | 
| 
       106 
105 
     | 
    
         
             
                  end
         
     | 
| 
      
 106 
     | 
    
         
            +
                end
         
     | 
| 
       107 
107 
     | 
    
         | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
      
 108 
     | 
    
         
            +
                private
         
     | 
| 
       109 
109 
     | 
    
         | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
      
 110 
     | 
    
         
            +
                def login_request?(identity_owner, user_params)
         
     | 
| 
      
 111 
     | 
    
         
            +
                  identity_owner && !user_params
         
     | 
| 
      
 112 
     | 
    
         
            +
                end
         
     | 
| 
       113 
113 
     | 
    
         | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
      
 114 
     | 
    
         
            +
                def identity_already_bound_to_different_user?(identity_owner, user)
         
     | 
| 
      
 115 
     | 
    
         
            +
                  identity_owner && user && identity_owner != user
         
     | 
| 
      
 116 
     | 
    
         
            +
                end
         
     | 
| 
       117 
117 
     | 
    
         | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
                  end
         
     | 
| 
      
 118 
     | 
    
         
            +
                def start_of_registration_process?(identity, user_params)
         
     | 
| 
      
 119 
     | 
    
         
            +
                  !identity && !user_params
         
     | 
| 
       121 
120 
     | 
    
         
             
                end
         
     | 
| 
       122 
121 
     | 
    
         
             
              end
         
     | 
| 
      
 122 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -5,19 +5,5 @@ module SimpleMobileOauth 
     | 
|
| 
       5 
5 
     | 
    
         
             
                included do
         
     | 
| 
       6 
6 
     | 
    
         
             
                  has_many :identities, as: :identifiable
         
     | 
| 
       7 
7 
     | 
    
         
             
                end
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
                def username
         
     | 
| 
       10 
     | 
    
         
            -
                  current_identity_info.try(:fetch, "nickname", "")
         
     | 
| 
       11 
     | 
    
         
            -
                end
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                def avatar_url
         
     | 
| 
       14 
     | 
    
         
            -
                  current_identity_info.try(:fetch, "image", "")
         
     | 
| 
       15 
     | 
    
         
            -
                end
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                private
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                def current_identity_info
         
     | 
| 
       20 
     | 
    
         
            -
                  identities.first.try(:info)
         
     | 
| 
       21 
     | 
    
         
            -
                end
         
     | 
| 
       22 
8 
     | 
    
         
             
              end
         
     | 
| 
       23 
9 
     | 
    
         
             
            end
         
     | 
    
        data/test/dummy/log/test.log
    CHANGED
    
    | 
         @@ -59,3 +59,39 @@ UserTest: test_has_many_identities 
     | 
|
| 
       59 
59 
     | 
    
         
             
              [1m[35mSQL (1.0ms)[0m  INSERT INTO "identities" ("created_at", "identifiable_id", "identifiable_type", "info", "provider", "uid", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?)  [["created_at", "2014-12-16 00:47:50.174806"], ["identifiable_id", 1], ["identifiable_type", "User"], ["info", "null"], ["provider", "provider"], ["uid", "abc"], ["updated_at", "2014-12-16 00:47:50.174806"]]
         
     | 
| 
       60 
60 
     | 
    
         
             
              [1m[36m (0.1ms)[0m  [1mRELEASE SAVEPOINT active_record_1[0m
         
     | 
| 
       61 
61 
     | 
    
         
             
              [1m[35m (0.8ms)[0m  rollback transaction
         
     | 
| 
      
 62 
     | 
    
         
            +
              [1m[36mActiveRecord::SchemaMigration Load (0.4ms)[0m  [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
         
     | 
| 
      
 63 
     | 
    
         
            +
              [1m[35m (0.1ms)[0m  begin transaction
         
     | 
| 
      
 64 
     | 
    
         
            +
            ----------------------------------
         
     | 
| 
      
 65 
     | 
    
         
            +
            UserTest: test_creates_an_identity
         
     | 
| 
      
 66 
     | 
    
         
            +
            ----------------------------------
         
     | 
| 
      
 67 
     | 
    
         
            +
              [1m[36m (0.0ms)[0m  [1mSAVEPOINT active_record_1[0m
         
     | 
| 
      
 68 
     | 
    
         
            +
              [1m[35mSQL (10.1ms)[0m  INSERT INTO "users" ("created_at", "updated_at") VALUES (?, ?)  [["created_at", "2014-12-27 03:53:45.375459"], ["updated_at", "2014-12-27 03:53:45.375459"]]
         
     | 
| 
      
 69 
     | 
    
         
            +
              [1m[36m (0.1ms)[0m  [1mRELEASE SAVEPOINT active_record_1[0m
         
     | 
| 
      
 70 
     | 
    
         
            +
              [1m[35m (0.1ms)[0m  SAVEPOINT active_record_1
         
     | 
| 
      
 71 
     | 
    
         
            +
              [1m[36mIdentity Exists (0.4ms)[0m  [1mSELECT  1 AS one FROM "identities"  WHERE ("identities"."uid" = 'abc' AND "identities"."provider" = 'provider' AND "identities"."identifiable_type" = 'User') LIMIT 1[0m
         
     | 
| 
      
 72 
     | 
    
         
            +
              [1m[35mSQL (1.1ms)[0m  INSERT INTO "identities" ("created_at", "identifiable_id", "identifiable_type", "info", "provider", "uid", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?)  [["created_at", "2014-12-27 03:53:45.499147"], ["identifiable_id", 1], ["identifiable_type", "User"], ["info", "null"], ["provider", "provider"], ["uid", "abc"], ["updated_at", "2014-12-27 03:53:45.499147"]]
         
     | 
| 
      
 73 
     | 
    
         
            +
              [1m[36m (0.1ms)[0m  [1mRELEASE SAVEPOINT active_record_1[0m
         
     | 
| 
      
 74 
     | 
    
         
            +
              [1m[35m (13.1ms)[0m  rollback transaction
         
     | 
| 
      
 75 
     | 
    
         
            +
              [1m[36m (0.1ms)[0m  [1mbegin transaction[0m
         
     | 
| 
      
 76 
     | 
    
         
            +
            ---------------------------------
         
     | 
| 
      
 77 
     | 
    
         
            +
            SimpleMobileOauthTest: test_truth
         
     | 
| 
      
 78 
     | 
    
         
            +
            ---------------------------------
         
     | 
| 
      
 79 
     | 
    
         
            +
              [1m[35m (0.0ms)[0m  rollback transaction
         
     | 
| 
      
 80 
     | 
    
         
            +
              [1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m  [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
         
     | 
| 
      
 81 
     | 
    
         
            +
              [1m[35m (0.1ms)[0m  begin transaction
         
     | 
| 
      
 82 
     | 
    
         
            +
            ----------------------------------
         
     | 
| 
      
 83 
     | 
    
         
            +
            UserTest: test_creates_an_identity
         
     | 
| 
      
 84 
     | 
    
         
            +
            ----------------------------------
         
     | 
| 
      
 85 
     | 
    
         
            +
              [1m[36m (0.0ms)[0m  [1mSAVEPOINT active_record_1[0m
         
     | 
| 
      
 86 
     | 
    
         
            +
              [1m[35mSQL (0.3ms)[0m  INSERT INTO "users" ("created_at", "updated_at") VALUES (?, ?)  [["created_at", "2014-12-27 03:54:33.860344"], ["updated_at", "2014-12-27 03:54:33.860344"]]
         
     | 
| 
      
 87 
     | 
    
         
            +
              [1m[36m (0.0ms)[0m  [1mRELEASE SAVEPOINT active_record_1[0m
         
     | 
| 
      
 88 
     | 
    
         
            +
              [1m[35m (0.0ms)[0m  SAVEPOINT active_record_1
         
     | 
| 
      
 89 
     | 
    
         
            +
              [1m[36mIdentity Exists (0.2ms)[0m  [1mSELECT  1 AS one FROM "identities"  WHERE ("identities"."uid" = 'abc' AND "identities"."provider" = 'provider' AND "identities"."identifiable_type" = 'User') LIMIT 1[0m
         
     | 
| 
      
 90 
     | 
    
         
            +
              [1m[35mSQL (1.5ms)[0m  INSERT INTO "identities" ("created_at", "identifiable_id", "identifiable_type", "info", "provider", "uid", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?)  [["created_at", "2014-12-27 03:54:33.914630"], ["identifiable_id", 1], ["identifiable_type", "User"], ["info", "null"], ["provider", "provider"], ["uid", "abc"], ["updated_at", "2014-12-27 03:54:33.914630"]]
         
     | 
| 
      
 91 
     | 
    
         
            +
              [1m[36m (0.1ms)[0m  [1mRELEASE SAVEPOINT active_record_1[0m
         
     | 
| 
      
 92 
     | 
    
         
            +
              [1m[35m (18.7ms)[0m  rollback transaction
         
     | 
| 
      
 93 
     | 
    
         
            +
              [1m[36m (0.1ms)[0m  [1mbegin transaction[0m
         
     | 
| 
      
 94 
     | 
    
         
            +
            ---------------------------------
         
     | 
| 
      
 95 
     | 
    
         
            +
            SimpleMobileOauthTest: test_truth
         
     | 
| 
      
 96 
     | 
    
         
            +
            ---------------------------------
         
     | 
| 
      
 97 
     | 
    
         
            +
              [1m[35m (0.1ms)[0m  rollback transaction
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: simple_mobile_oauth
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Lin He
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2014-12- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-12-27 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rails
         
     |