mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Refactor user controller, create action, mostly.
The gist of the commit are a few improvements in the create action, where: * long boolean statemenst have been wrapped in smaller more readable methods. * the 3rd party user info creation has been extracted (still in controller) * a small helper method for creating a new user from params (to reduce visual clutter) * specs have been added where I came across untested methods/branches Other changes are more trivial like formatting and whitespace fixes. Hope this helps. Regards.
This commit is contained in:
@@ -102,6 +102,15 @@ class User < ActiveRecord::Base
|
||||
find_available_username_based_on(name)
|
||||
end
|
||||
|
||||
def self.new_from_params(params)
|
||||
user = User.new
|
||||
user.name = params[:name]
|
||||
user.email = params[:email]
|
||||
user.password = params[:password]
|
||||
user.username = params[:username]
|
||||
user
|
||||
end
|
||||
|
||||
def self.create_for_email(email, opts={})
|
||||
username = suggest_username(email)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user