diff options
Diffstat (limited to 'app/models/user_session.rb')
-rw-r--r-- | app/models/user_session.rb | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/app/models/user_session.rb b/app/models/user_session.rb index d1c0711..90592d1 100644 --- a/app/models/user_session.rb +++ b/app/models/user_session.rb @@ -4,29 +4,17 @@ class UserSession extend ActiveModel::Naming def authenticate(auth_opts) - authenticate_via(auth_opts) do |network, options| - network.authenticate(options) - end - end - - def authenticate_by_token(auth_opts) - result = authenticate_via(auth_opts) do |network, options| - network.authenticate_by_token(options) - end - - result - end - - private - - def authenticate_via(options, &block) - user = block.call(Network.new, options) + network = Network.new + user = network.authenticate(auth_opts) if user + user["access_token"] = auth_opts[:access_token] return User.new(user) else nil end + + user rescue nil end |