- @user.status = "pending"
- @user.data_public = true
- @user.description = "" if @user.description.nil?
- @user.creation_ip = request.remote_ip
- @user.languages = request.user_preferred_languages
- @user.terms_agreed = Time.now.getutc
- @user.terms_seen = true
- @user.openid_url = nil if @user.openid_url and @user.openid_url.empty?
-
- if @user.save
- flash[:piwik_goal] = PIWIK_SIGNUP_GOAL if defined?(PIWIK_SIGNUP_GOAL)
- flash[:notice] = t 'user.new.flash create success message', :email => @user.email
- Notifier.signup_confirm(@user, @user.tokens.create(:referer => session.delete(:referer))).deliver
- session[:token] = @user.tokens.create.token
- redirect_to :action => 'login', :referer => params[:referer]
- else
- render :action => 'new', :referer => params[:referer]
+ if check_signup_allowed(@user.email)
+ @user.data_public = true
+ @user.description = "" if @user.description.nil?
+ @user.creation_ip = request.remote_ip
+ @user.languages = http_accept_language.user_preferred_languages
+ @user.terms_agreed = Time.now.getutc
+ @user.terms_seen = true
+ @user.openid_url = nil if @user.openid_url and @user.openid_url.empty?
+
+ if @user.save
+ flash[:piwik_goal] = PIWIK["goals"]["signup"] if defined?(PIWIK)
+
+ referer = welcome_path
+
+ begin
+ uri = URI(session[:referer])
+ /map=(.*)\/(.*)\/(.*)/.match(uri.fragment) do |m|
+ editor = Rack::Utils.parse_query(uri.query).slice('editor')
+ referer = welcome_path({'zoom' => m[1],
+ 'lat' => m[2],
+ 'lon' => m[3]}.merge(editor))
+ end
+ rescue
+ # Use default
+ end
+
+ if @user.status == "active"
+ session[:referer] = referer
+ successful_login(@user)
+ else
+ session[:token] = @user.tokens.create.token
+ Notifier.signup_confirm(@user, @user.tokens.create(:referer => referer)).deliver
+ redirect_to :action => 'confirm', :display_name => @user.display_name
+ end
+ else
+ render :action => 'new', :referer => params[:referer]
+ end