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 7431183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:15:21+00:00 2026-05-29T09:15:21+00:00

After following: https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview I can sign up a user via Facebook. But I’m struggling

  • 0

After following:

https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview

I can sign up a user via Facebook. But I’m struggling to define my own redirects.

Obviously it’s perfect that an existing user that already facebook signed up/in redirects to my app and continues on, but it’s the case of the users who are newly created via facebook i’m interested in.

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
  def facebook
    # You need to implement the method below in your model
    @user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)

    if @user.persisted?
      flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook"
      sign_in_and_redirect @user, :event => :authentication
    else
      session["devise.facebook_data"] = request.env["omniauth.auth"]
      redirect_to new_user_registration_url
    end
  end
end

What does user.persisted mean? find_for_facebook_oauth does the same as the devise wiki page stipulates; i.e. finds the user by email and returns it if they exists, or creates a new user with a autogen password if not.

But I need it to redirect newly created users to a page where they set their password. I don’t want the stub password to persist, I want users to immediately be presented with a screen to a) confirm their name and b) confirm their password.

I have such a screen implemented for people who accept invites (via https://github.com/scambra/devise_invitable/ ) that is in views/devise/invitations/edit – which would be perfectly suitable for this if it will work.

Where should I add the redirection to and what format would this sort of redirection take? I find the facebook method above quite confusing to interpret. I can’t understand why it would ever redirect to a new user registration url – the user is created or exists, so what does the persists relate to?

Obviously confused, so help appreciated. 🙂

Thanks,

Dave

  • 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-05-29T09:15:22+00:00Added an answer on May 29, 2026 at 9:15 am

    the .persisted? method checks whether that record is saved in your database. It’s the method’s way of checking if the user was successfully found or created. If not, it redirects to the new_user_registration_url because sign-up was unsuccessful (allowing the user to try again).

    To redirect based on whether the user is new or not, you could check the user object for some flag that indicates they’re new. You mentioned password, so something like this could work (untested):

    if @user.persisted?
      flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook"
      if @user.password.exists?
        sign_in_and_redirect @user, :event => :authentication
      else
        sign_in @user
        redirect_to ______ #insert path to set password etc
      end
    else
      session["devise.facebook_data"] = request.env["omniauth.auth"]
      redirect_to new_user_registration_url
    end
    

    an alternative (if you want to get more fine-tuned) you may want to customize after_sign_in_path_for(resource_or_scope), as described on the Devise wiki

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

Sidebar

Related Questions

Accordng to https://github.com/reddit/reddit/wiki/API I need to: Post the following to http://www.reddit.com/api/submit : uh=f0f0f0f0&kind=link&url=yourlink.com&sr=funny &title=omg-look-at-this&id%23newlink&r=funny&renderstyle=html
After installing rvm, using the following: $ curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer > rvm-installer $ bash
I tried to install node.js by following instructions here: https://github.com/joyent/node/wiki/Building-node.js-on-Cygwin-(Windows ) I got these
Trying to use the Phirehose class from https://github.com/fennb/phirehose After uploading everything to the server,
my setup is ubuntu - gitolite - msysgit. After following this tutorial : https://sites.google.com/site/senawario/home/gitolite-tutorial
I am trying to import the library project from https://github.com/JakeWharton/Android-ViewPagerIndicator by doing the following
immediately after has_many_polymorphs install with ruby script/plugin install git://github.com/fauna/has_many_polymorphs.git i start getting following error
I have played with: https://github.com/experteer/autocompleteTrigger/ as following: (function ($, window, document, undefined) { $.widget(ui.autocompleteTrigger,
I have been using https://github.com/Redth/APNS-Sharp to send push notification message to all devices where
https://github.com/doubleencore/DETweetComposeViewController I followed twitter integration here for supporting twitter for both ios5 and ios4.

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.