mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 19:27:52 +01:00
Multiple fixes and improvements in invitations system (#402)
This commit is contained in:
committed by
GitHub
parent
d1faf059ee
commit
3c6b885391
@@ -47,10 +47,11 @@ class InvitationsController < ApplicationController
|
||||
body = invitation_params[:body]
|
||||
|
||||
invitation_token = SecureRandom.hex(16)
|
||||
invitation = Invitation.new(email: to, token_digest: Digest::SHA256.hexdigest(invitation_token))
|
||||
subject = "[TEST] " + subject
|
||||
body_with_link = body.gsub('%link%', get_url_for(method(:new_user_registration_url), options: { invitation_token: invitation_token, email: to }))
|
||||
|
||||
InvitationMailer.invite(to: to, subject: subject, body: body_with_link).deliver_later
|
||||
InvitationMailer.invite(invitation: invitation, subject: subject, body: body_with_link).deliver_now
|
||||
|
||||
render json: {}, status: :ok
|
||||
end
|
||||
|
||||
@@ -1 +1 @@
|
||||
<%= @body %>
|
||||
<%= simple_format(@body) %>
|
||||
@@ -40,15 +40,24 @@ class OAuthSignInUserWorkflow
|
||||
end
|
||||
full_name ||= I18n.t('defaults.user_full_name')
|
||||
|
||||
user = User.new(
|
||||
email: email,
|
||||
full_name: full_name,
|
||||
password: Devise.friendly_token,
|
||||
has_set_password: false,
|
||||
status: 'active'
|
||||
)
|
||||
user.skip_confirmation
|
||||
user.save
|
||||
ActiveRecord::Base.transaction do
|
||||
user = User.new(
|
||||
email: email,
|
||||
full_name: full_name,
|
||||
password: Devise.friendly_token,
|
||||
has_set_password: false,
|
||||
status: 'active'
|
||||
)
|
||||
user.skip_confirmation
|
||||
user.save
|
||||
|
||||
# if there is a pending invitation for this email, mark it as accepted
|
||||
invitation = Invitation.find_by(email: email)
|
||||
if invitation && invitation.accepted_at.nil?
|
||||
invitation.accepted_at = Time.now
|
||||
invitation.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return user
|
||||
|
||||
Reference in New Issue
Block a user