Commit 524373dba6e746bce012b57f7a0752ae09ebe451
1 parent
cebdccf8
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Needs to be compatible with older versions
Showing
3 changed files
with
14 additions
and
4 deletions
Show diff stats
app/models/user.rb
lib/noosfero/api/entities.rb
lib/noosfero/api/session.rb
... | ... | @@ -43,11 +43,14 @@ module Noosfero |
43 | 43 | # this return is just to improve the clarity of the execution path |
44 | 44 | return unless test_captcha(remote_ip, params, environment) |
45 | 45 | user = User.new(attrs) |
46 | - if user.save | |
47 | - user.generate_private_token! if user.activated? | |
48 | - present user, :with => Entities::UserLogin | |
46 | + person = Person.new(name: params[:name], identifier: user.login) | |
47 | + user.person = person | |
48 | + if user.signup | |
49 | + user.generate_private_token! if user.activated? | |
50 | + present user, :with => Entities::UserLogin | |
49 | 51 | else |
50 | - message = user.errors.to_json | |
52 | + user.destroy | |
53 | + message = user.errors.as_json.merge(person.errors.as_json).to_json | |
51 | 54 | render_api_error!(message, 400) |
52 | 55 | end |
53 | 56 | end | ... | ... |