Newer
Older
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class RegistrationsController < Devise::RegistrationsController
before_action :check_registrations_open_or_valid_invite!, :check_valid_invite!
layout ->(c) { request.format == :mobile ? "application" : "with_header" }, :only => [:new]
@user.process_invite_acceptence(invite) if invite.present?
flash[:notice] = I18n.t 'registrations.create.success'
@user.send_welcome_message
sign_in_and_redirect(:user, @user)
logger.info "event=registration status=successful user=#{@user.diaspora_handle}"
flash.now[:error] = @user.errors.full_messages.join(" - ")
logger.info "event=registration status=failure errors='#{@user.errors.full_messages.join(', ')}'"
Jason Robinson
a validé
render :action => 'new', :layout => 'with_header'
def new
super
end
private
Maxwell Salzberg
a validé
def check_valid_invite!
return true if AppConfig.settings.enable_registrations? #this sucks
Maxwell Salzberg
a validé
flash[:error] = t('registrations.invalid_invite')
redirect_to new_user_session_path
end
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
params.require(:user).permit(:username, :email, :getting_started, :password, :password_confirmation, :language, :disable_mail, :invitation_service, :invitation_identifier, :show_community_spotlight_in_stream, :auto_follow_back, :auto_follow_back_aspect_id, :remember_me, :captcha, :captcha_key)