Class: Thincloud::Authentication::CreateInvitationForUser

Inherits:
Object
  • Object
show all
Defined in:
app/services/thincloud/authentication/create_invitation_for_user.rb

Overview

Public: Execute the workflow steps to create and identity and send an invitation email

Class Method Summary collapse

Class Method Details

.call(user, params) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/services/thincloud/authentication/create_invitation_for_user.rb', line 6

def self.call(user, params)
  password = SecureRandom.uuid
  identity = Identity.create!(user: user, name: params[:name],
                              email: params[:email], password: password,
                              password_confirmation: password)
  Identity.verify!(identity.verification_token)
  identity.generate_password_reset!
  InvitationsMailer.new_invitation(identity.id).deliver
  true
rescue ActiveRecord::RecordInvalid
  false
end