diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index b29887112d2f5dde61e371a909b6495abba64adb..8a784dcfbc279932e08e19807b465b1c52dc4aca 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -22,7 +22,7 @@ class RegistrationsController < Devise::RegistrationsController end end - def update + def update super end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 030cfe56d0f3c495641bcb5c3366de87aa754b02..6a12c1842f9a39af5525ee42579dba392cc791e7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -5,10 +5,11 @@ class UsersController < ApplicationController require File.join(Rails.root, 'lib/diaspora/ostatus_builder') require File.join(Rails.root, 'lib/diaspora/exporter') + require File.join(Rails.root, 'lib/diaspora/importer') require File.join(Rails.root, 'lib/collect_user_photos') - before_filter :authenticate_user!, :except => [:new, :create, :public] + before_filter :authenticate_user!, :except => [:new, :create, :public, :import] respond_to :html @@ -81,6 +82,28 @@ class UsersController < ApplicationController def invite User.invite!(:email => params[:email]) end + + + def import + xml = params[:upload][:file].read + + params[:user][:diaspora_handle] = 'asodij@asodij.asd' + + + begin + importer = Diaspora::Importer.new(Diaspora::Parsers::XML) + importer.execute(xml, params[:user]) + flash[:notice] = "hang on a sec, try logging in!" + + rescue Exception => e + flash[:error] = "Derp, something went wrong: #{e.message}" + end + + redirect_to new_user_registration_path + #redirect_to user_session_path + end + + private def prep_image_url(params) diff --git a/app/views/registrations/new.html.haml b/app/views/registrations/new.html.haml index 7e74a215708839f36e96282e23fa79713d610e5f..cea31ff78e0f076f9c7f2d45c80c033775451328 100644 --- a/app/views/registrations/new.html.haml +++ b/app/views/registrations/new.html.haml @@ -24,3 +24,27 @@ = pr.text_field :last_name = f.submit t('.sign_up') = render :partial => "devise/shared/links" + + +%br +%br + +%h2 or, upload yourself + + += form_tag '/users/import', :multipart => true do + + %p + = label_tag 'user[email]' + = text_field_tag 'user[email]' + %p + = label_tag 'user[password]' + = password_field_tag 'user[password]' + %p + = label_tag 'user[password_confirmation]' + = password_field_tag 'user[password_confirmation]' + + %label Select File + = file_field 'upload', 'file' + = submit_tag "Upload" + diff --git a/config/routes.rb b/config/routes.rb index 8fbd132a870e2a136e3ac78457001a200f1287cf..47e73807ba1c7c1f004e20d974c7630435af5556 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,6 +16,7 @@ Diaspora::Application.routes.draw do # added public route to user match 'public/:username', :to => 'users#public' match 'users/export', :to => 'users#export' + match 'users/import', :to => 'users#import' match 'users/export_photos', :to => 'users#export_photos' resources :users, :except => [:create, :new, :show] diff --git a/spec/lib/importer_spec.rb b/spec/lib/importer_spec.rb index d243ae345d1f607310c2f21cd8d0521e2a4a8418..7f5469cc105477068050e00fc192e86a46555251 100644 --- a/spec/lib/importer_spec.rb +++ b/spec/lib/importer_spec.rb @@ -131,9 +131,6 @@ describe Diaspora::Importer do @user.serialized_private_key.should == @old_user.serialized_private_key end - it 'should ensure a match between persons public and private keys' do - pending - end end describe '#parse_aspects' do