First pass at having a custom registrationsController
This commit is contained in:
parent
ee89bfaf8f
commit
e0ffc8bba0
6 changed files with 24 additions and 17 deletions
18
app/controllers/registrations_controller.rb
Normal file
18
app/controllers/registrations_controller.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Copyright (c) 2010, Disapora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
class RegistrationsController < Devise::RegistrationsController
|
||||
def new
|
||||
super
|
||||
end
|
||||
|
||||
def create
|
||||
User.instantiate!(params[:user])
|
||||
redirect_to root_url
|
||||
end
|
||||
|
||||
def update
|
||||
super
|
||||
end
|
||||
end
|
||||
|
|
@ -35,8 +35,6 @@ class User
|
|||
many :aspects, :class_name => 'Aspect'
|
||||
|
||||
|
||||
before_create :setup_person
|
||||
after_create :set_diaspora_handle
|
||||
after_create :seed_aspects
|
||||
|
||||
before_save :downcase_username
|
||||
|
|
@ -288,10 +286,10 @@ class User
|
|||
end
|
||||
|
||||
###Helpers############
|
||||
def self.instantiate!( opts = {} )
|
||||
#opts[:person][:diaspora_handle] = opts[:email]
|
||||
def self.instantiate( opts = {} )
|
||||
opts[:person][:diaspora_handle] = "#{opts[:username]}@#{opts[:url]}"
|
||||
opts[:person][:serialized_key] = generate_key
|
||||
User.create!(opts)
|
||||
User.create(opts)
|
||||
end
|
||||
|
||||
def seed_aspects
|
||||
|
|
@ -313,16 +311,6 @@ class User
|
|||
"#{self.username}@#{self.terse_url}"
|
||||
end
|
||||
|
||||
def setup_person
|
||||
self.person.serialized_key ||= User.generate_key.export
|
||||
self.person.save!
|
||||
end
|
||||
|
||||
def set_diaspora_handle
|
||||
self.person.diaspora_handle ||= self.diaspora_handle
|
||||
self.person.save
|
||||
end
|
||||
|
||||
def downcase_username
|
||||
username.downcase!
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ Diaspora::Application.routes.draw do
|
|||
|
||||
#routes for devise, not really sure you will need to mess with this in the future, lets put default,
|
||||
#non mutable stuff in anohter file
|
||||
devise_for :users
|
||||
devise_for :users, :controllers => {:registrations => "registrations"}
|
||||
match 'login', :to => 'devise/sessions#new', :as => "new_user_session"
|
||||
match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session"
|
||||
match 'get_to_the_choppa', :to => 'devise/registrations#new', :as => "new_user_registration"
|
||||
match 'get_to_the_choppa', :to => 'registrations#new', :as => "new_user_registration"
|
||||
|
||||
#public routes
|
||||
#
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ require 'config/environment'
|
|||
|
||||
host = "localhost:3000"
|
||||
url = "http://#{host}/"
|
||||
username = "tom"
|
||||
# Create seed user
|
||||
user = User.instantiate!( :email => "tom@tom.joindiaspora.com",
|
||||
:username => "tom",
|
||||
|
|
|
|||
Loading…
Reference in a new issue