Giter Club home page Giter Club logo

Comments (3)

luxflux avatar luxflux commented on July 26, 2024

As CASino does not support user creation (sign up), only login (sign in), I assume you want to do this in another app. You can use the API to sign the new user in, check #38 and #40 for an example.

from casino.

nicolasiensen avatar nicolasiensen commented on July 26, 2024

I'm reusing LoginCredentialAcceptor to auto login users. In my case users are signing up with Devise, after sign up they are redirected to an action I built in UsersController#sign_in.

This action receives username and password as get parameters , and deal with LoginCredentialAcceptor to login the signed up user.

I also had to include CASino::ProcessorConcern::LoginTickets in the top of the controller.

from casino.

nozpheratu avatar nozpheratu commented on July 26, 2024

For future visitors, here's a more up-to-date example using the ActiveRecord authenticator:

class RegistrationsController < Devise::RegistrationsController
  include CASino::SessionsHelper

  private

  def sign_up(resource_name, resource)
    return unless params.has_key?(:service)
    data = { authenticator: 'ActiveRecord', user_data: { username: resource.email }}
    sign_in(data)
  end

  # Prevents render/redirect conflicts between Devise & CASino, also makes the
  # service_with_ticket_url available for Devise to follow after registration.
  def handle_signed_in_with_service(tgt, options)
    if !service_allowed?(params[:service])
      @service = params[:service]
      render 'casino/sessions/service_not_allowed', status: 403
    else
      @url = acquire_service_ticket(tgt, params[:service], options).service_with_ticket_url
    end
  end

  def after_sign_up_path_for(resource)
    params.has_key?(:service) ? @url : super
  end
end

In order for this to work you'll need to ensure the service param is forwarded through the registration pipeline (e.g., registration link on the login page and the following registration form tag). I'm sure this example can be improved but it should give you a decent starting point.

Edit: Make sure you're only passing params[:service] and and not the entire params hash in your devise links/form tags. Otherwise you'll break devise as your params hash content will override anything you enter into the forms.

from casino.

Related Issues (20)

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.