Commit ba8deb78 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻 Committed by Kaspar
Browse files

small refactor of volunteer user creation

- code slimmer
- dont send invite_sent notification in case user creation and invitation fails
parent 5c2b5524
......@@ -45,11 +45,11 @@ class VolunteersController < ApplicationController
private
def invite_volunteer_user
new_user = User.new(email: @volunteer.contact.contact_emails.first.body,
password: Devise.friendly_token, role: 'volunteer')
new_user.save
@volunteer.user = new_user
new_user.invite!
new_user = User.new(
email: @volunteer.email, password: Devise.friendly_token,
role: 'volunteer', volunteer: @volunteer
)
return unless new_user.save && new_user.invite!
redirect_to volunteers_path, notice: t('invite_sent', email: new_user.email)
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment