Skip to content
Extraits de code Groupes Projets
registrations_controller.rb 1,28 ko
Newer Older
  • Learn to ignore specific revisions
  • danielgrippi's avatar
    danielgrippi a validé
    #   Copyright (c) 2010-2011, Diaspora Inc.  This file is
    
    Raphael's avatar
    Raphael a validé
    #   licensed under the Affero General Public License version 3 or later.  See
    
    #   the COPYRIGHT file.
    
    class RegistrationsController < Devise::RegistrationsController
    
      before_filter :check_registrations_open_or_vaild_invite!
    
        @user.process_invite_acceptence(invite) if invite.present?
    
    
          flash[:notice] = I18n.t 'registrations.create.success'
    
          sign_in_and_redirect(:user, @user)
    
    Raphael's avatar
    Raphael a validé
          Rails.logger.info("event=registration status=successful user=#{@user.diaspora_handle}")
    
          @user.errors.delete(:person)
    
          flash[:error] = @user.errors.full_messages.join(";")
    
          Rails.logger.info("event=registration status=failure errors='#{@user.errors.full_messages.join(', ')}'")
    
      def check_registrations_open_or_vaild_invite!
        return true if invite.present?
    
        if AppConfig[:registrations_closed]
    
          flash[:error] = t('registrations.closed')
    
          redirect_to new_user_session_path
    
    
      def invite
        if params[:invite].present?
          @invite ||= InvitationCode.find_by_token(params[:invite][:token])
        end
      end
      
      helper_method :invite