Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7895263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:36:02+00:00 2026-06-03T07:36:02+00:00

Hi I am using omniauth in my application. I created the application without using

  • 0

Hi I am using omniauth in my application. I created the application without using devise. So I wrote all the methods for encryption manually. I am trying to integrate imniauth with my application but I am encountering loads of problems. I made an authentications controller:

class AuthenticationsController < ApplicationController
  def index
    @authentications = current_user.authentications if current_user
  end

  def create
    omniauth = request.env["omniauth.auth"]
    authentication= Authentication.find_by_provider_and_uid(omniauth['provider'],omniauth['uid'])
    if authentication
      flash[:notice]= "Signed in with " + omniauth['provider'] + " Successfully"
      sign_in(authentication.user)
      redirect_back_or authentication.user
    elsif current_user
      current_user.authentications.create!(:provider => omniauth['provider'],:uid => omniauth['uid'])
      flash[:notice]="authentication successfull"
      redirect_to authentications_url
    else

   authenticate= Authentication.create!(:provider => omniauth['provider'], :uid => omniauth['uid'])
   flash[:notice] = "You still need to fill up the following"
   # This is where I have doubt as to how should I proceed. Should I first create authentication for omniauth and then redirect or just send everything together and then create in sign up?
   # session[:omniauth] = omniauth.except('extra')
   #  redirect_to signup_path(omniauth)

 end
end

  def destroy
    @authentication = current_user.authentications.find(params[:id])
    @authentication.destroy
    flash[:notice] = "Successfully destroyed authentication."
    redirect_to authentications_url
  end
end

My User controller is as follows:

class UsersController < ApplicationController
  before_filter :authenticate, :except => [:show, :new, :create]
  before_filter :correct_user, :only => [:edit, :update]
  before_filter :admin_user,   :only => :destroy

# Id ont know what to do with omniauth here! :( 
  def new(omniauth)
    @user  = User.new
    @title = "Sign up"
  end

  def create
    @user = User.new(params[:user])
    if @user.save
      sign_in @user
      redirect_to @user, :flash => { :success => "Welcome to the World Student Alliance!" }
    else
      @title = "Sign up"
      render 'new'
    end
  end

  def edit
    @title = "Edit user"
  end

  def update
    if @user.update_attributes(params[:user])
      redirect_to @user, :flash => { :success => "Profile updated." }
    else
      @title = "Edit user"
      render 'edit'
    end
  end

  def destroy
    @user.destroy
    redirect_to users_path, :flash => { :success => "User destroyed." }
  end

  private

    def correct_user
      @user = User.find(params[:id])
      redirect_to(root_path) unless current_user?(@user)
    end

    def admin_user
      @user = User.find(params[:id])
      redirect_to(root_path) if !current_user.admin? || current_user?(@user)
    end
end

and sessions controller is as follows:

class SessionsController < ApplicationController
  skip_before_filter :check_sign_in, :only => [:new, :create]
  def new
    @title = "Sign in"
  end

  def create
    user = User.authenticate(params[:session][:email],
                             params[:session][:password])
    if user.nil?
      flash.now[:error] = "Invalid email/password combination."
      @title = "Sign in"
      render 'new'
    else
      sign_in user
      redirect_back_or user
    end
  end

  def destroy
    sign_out
    redirect_to root_path
  end
end

Each user has many authentications and each authentication belongs to a user

class Authentication < ActiveRecord::Base
  belongs_to :user
end

class User < ActiveRecord::Base
  has_many :authentications
.......

The following are the scenarios I considered:

  1. User is logged in and wants to connect with his twitter. ( Completed without errors)
  2. User is already a registered user and wants to use twitter for signing in every time( Completed without errors)

  3. User is not registered and wants to use twitter for authentication. If its basic authentication then it is done but I need to make the user enter few details like country, gender, department etc. This is where everything is goign wrong. I am able to create an authentication and escape him to the sign in form but when user is signed in from fb or twitter he should not have to enter the password fields. This is my problem. Could anyone please let me know of what I should be doing to get over this error. Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:36:04+00:00Added an answer on June 3, 2026 at 7:36 am

    I do something similar in a recent application – using Omniauth for authentication and allowing multiple authentications per user. For your case 3.) I create the user and the authentication first; then send them to a specific form (not the signup form) for filling out the rest of their profile.

    This ‘extra’ form only comes into play if the required fields are not complete, otherwise they get redirected to the user show page. Seems to work well for me.

    Edit: replace your current username/password gubbins with the Omniauth Identiy strategy: https://github.com/intridea/omniauth-identity. This way you have all your authentication handled by Omniauth. Believe me, your life will be simpler if you take out your hand-made password authentication code and replace it with Omniauth identity.

    For the avoidance of doubt, by having both Twitter and Identity strategies in place it means that you are giving your users a choice as to how they authenticate. They may use either Twitter or username/password to authenticate. Both get the same job done, however, if they use Twitter then you never see the password information (which is fine).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a Rails application using Devise. Devise is all set up even omniauth.
I am using devise and create login with Facebook using omniauth, but having problem
I'm using Rails, Devise, and Omniauth, and I'm trying to login using facebook connect.
Using OmniAuth 1.1.0 with Devise 2.0.4 I'm getting this error when trying to connect
I'm using omniauth without devise for authentication, as I like it's simplicity. In addition
I am using devise omniauth in my rails application, here is the User class
I'm developing a Rails 3.0 application and am using OmniAuth + Identity for authentication
There is a lot of information about using OmniAuth and Devise to be able
We have a web app running on Rails, using Devise and OmniAuth for user
Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.