Skip to content

Use the new Blizzard API so we can get rid of the change-your-portrait authentication system #30

Open

Description

@dsjoerg

From @dsjoerg on August 22, 2014 11:52

Copied from original issue: dsjoerg/ggtracker#11

Activity

  1. dsjoerg commented on Apr 18, 2016

    @dsjoerg
    MemberAuthor

    From @pencil on August 24, 2014 9:34

    I'm currently unable to authenticate my account:
    screenshot 2014-08-24 11 32 20

    Are you already working on this feature? I'd love to implement this and open up a PR 😁

  2. dsjoerg commented on Apr 18, 2016

    @dsjoerg
    MemberAuthor

    I'm not currently working on this, go for it!

  3. dsjoerg commented on Apr 18, 2016

    @dsjoerg
    MemberAuthor

    Also, I would be happy to manually authenticate your account, let me know what your bnet URL is. And sometimes the issue happens due to adblock, you could try disabling that.

    But of course if you implement this one then all these issue will go away, it'll be more robust and you'll make a lot of people happy :)

  4. dsjoerg commented on Apr 18, 2016

    @dsjoerg
    MemberAuthor

    From @pencil on September 11, 2014 23:13

    Sorry, life got in the way. 😞

    Although Blizzard recommends using a library to do the authentication, I did not manage to find a fitting gem. There is of course omniauth but I think it would be a misfit in this case, given that you don't want to use the Battle.net account as the actual login for the website. I'd therefore go for a custom solution but did just not find the time to implement it yet.

  5. dsjoerg commented on Apr 18, 2016

    @dsjoerg
    MemberAuthor

    omniauth would be a good way to go, and would not require that battle.net be used for logging in to the website.

    i've done something similar on another site i built: superego.herokuapp.com. on that site you can link your account to your fitbit, runkeeper and jawbone accounts.

    the way i do it there is:

    in app/views/users/show.html.erb:

    <% if !@user.linked?(FITBIT) %>
     <p><a href="/auth/fitbit">Link with Fitbit</a></p>
    <% end %>
    

    when the users clicks on the /auth/fitbit link, a bunch of omniauth magic happens, after which the user is redirected to /auth/fitbit/callback, and the params have what we need to complete the connection.

    in routes.rb:

    get '/auth/:provider/callback', to: 'linked_accounts#link_to_provider'

    then linked_accounts_controller.rb is:

    class LinkedAccountsController < ApplicationController
      before_action :authenticate_user!
    
      def auth_hash
          return request.env['omniauth.auth']
      end
    
      def link_to_provider
        current_user.set_omniauth(auth_hash)
    
        redirect_to after_sign_in_path_for(current_user)
      end
    end
    

    and in user.rb we have:

      def set_omniauth(auth)
        linked_account = LinkedAccount.find_or_initialize_by(provider: auth['provider'],
                                                             user: self)
    
        case auth['provider']
        when FITBIT
          linked_account.update_attributes(:oauth_token => auth['credentials']['token'],
                                           :oauth_secret => auth['credentials']['secret']
                                           )
        end
    
        linked_account.save
      end
    

    I can share my superego repo with you if you want to play with it more.

  6. dsjoerg commented on Apr 17, 2017

    @dsjoerg
    MemberAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions