GithubHelp home page GithubHelp logo

Comments (3)

Awea avatar Awea commented on August 22, 2024

I have updated the user method in auth_controller to send correct information :

def user
    hash = {
      :provider => 'josh_id',
      :id => current_user.id.to_s,
      :info => {
         :email => current_user.email
      },
      :extra => {
        :first_name => current_user.first_name,
        :last_name => current_user.last_name
      }
    }

    render :json => hash.to_json
  end

from sso-devise-omniauth-provider.

Awea avatar Awea commented on August 22, 2024

Then I change the create methode inside UserSessionsController :

def create
    omniauth = env['omniauth.auth']
    logger.debug "+++ #{omniauth}"
    logger.debug "+++ #{omniauth.extra.raw_info.extra}"

    user = User.find_by_uid(omniauth['uid'])
    if not user
      # New user registration
    user = User.create!(:uid        => omniauth['uid'],
                        :first_name => omniauth.extra.raw_info.extra.first_name,
                        :last_name  => omniauth.extra.raw_info.extra.last_name)
    end

    # Currently storing all the info
    session[:user_id] = omniauth

    flash[:notice] = "Successfully logged in"
    redirect_to root_path
  end

from sso-devise-omniauth-provider.

gautamrege avatar gautamrege commented on August 22, 2024

Your lookup is wrong.

In AuthController, you have 'extra.first_name' but in the UserSessionsController you have 'extra.raw_info.extra.first_name'

Change AuthController#user to

...
:extra => { 
   :raw_info => {
      :first_name => current_user.first_name,
      :last_name => current_user.last_name
   }
}

and in UserSessionsController#create

user = User.create!(:uid        => omniauth['uid'],
                        :first_name => omniauth.extra.raw_info.first_name,
                        :last_name  => omniauth.extra.raw_info.last_name)
    end

Did the logger info print differently? Reopen if this is an issue.

from sso-devise-omniauth-provider.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.