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'
|
many :aspects, :class_name => 'Aspect'
|
||||||
|
|
||||||
|
|
||||||
before_create :setup_person
|
|
||||||
after_create :set_diaspora_handle
|
|
||||||
after_create :seed_aspects
|
after_create :seed_aspects
|
||||||
|
|
||||||
before_save :downcase_username
|
before_save :downcase_username
|
||||||
|
|
@ -288,10 +286,10 @@ class User
|
||||||
end
|
end
|
||||||
|
|
||||||
###Helpers############
|
###Helpers############
|
||||||
def self.instantiate!( opts = {} )
|
def self.instantiate( opts = {} )
|
||||||
#opts[:person][:diaspora_handle] = opts[:email]
|
opts[:person][:diaspora_handle] = "#{opts[:username]}@#{opts[:url]}"
|
||||||
opts[:person][:serialized_key] = generate_key
|
opts[:person][:serialized_key] = generate_key
|
||||||
User.create!(opts)
|
User.create(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
def seed_aspects
|
def seed_aspects
|
||||||
|
|
@ -313,16 +311,6 @@ class User
|
||||||
"#{self.username}@#{self.terse_url}"
|
"#{self.username}@#{self.terse_url}"
|
||||||
end
|
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
|
def downcase_username
|
||||||
username.downcase!
|
username.downcase!
|
||||||
end
|
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,
|
#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
|
#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 'login', :to => 'devise/sessions#new', :as => "new_user_session"
|
||||||
match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_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
|
#public routes
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ require 'config/environment'
|
||||||
|
|
||||||
host = "localhost:3000"
|
host = "localhost:3000"
|
||||||
url = "http://#{host}/"
|
url = "http://#{host}/"
|
||||||
|
username = "tom"
|
||||||
# Create seed user
|
# Create seed user
|
||||||
user = User.instantiate!( :email => "tom@tom.joindiaspora.com",
|
user = User.instantiate!( :email => "tom@tom.joindiaspora.com",
|
||||||
:username => "tom",
|
:username => "tom",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue