Skip to content
Extraits de code Groupes Projets
Valider 800e701f rédigé par Raphael Sofaer's avatar Raphael Sofaer
Parcourir les fichiers

Document User#accept_invitation

parent 305c107b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -248,9 +248,15 @@ class User < ActiveRecord::Base ...@@ -248,9 +248,15 @@ class User < ActiveRecord::Base
end end
end end
# This method is called when an invited user accepts his invitation
#
# @param [Hash] opts the options to accept the invitation with
# @option opts [String] :username The username the invited user wants.
# @option opts [String] :password
# @option opts [String] :password_confirmation
def accept_invitation!(opts = {}) def accept_invitation!(opts = {})
log_string = "event=invitation_accepted username=#{opts[:username]} uid=#{self.id} " log_hash = {:event => :invitation_accepted, :username => opts[:username], :uid => self.id}
log_string << "inviter=#{invitations_to_me.first.sender.diaspora_handle} " if invitations_to_me.first log_hash[:inviter] = invitations_to_me.first.sender.diaspora_handle if invitations_to_me.first
begin begin
if self.invited? if self.invited?
self.setup(opts) self.setup(opts)
...@@ -259,15 +265,15 @@ class User < ActiveRecord::Base ...@@ -259,15 +265,15 @@ class User < ActiveRecord::Base
self.password_confirmation = opts[:password_confirmation] self.password_confirmation = opts[:password_confirmation]
self.save! self.save!
invitations_to_me.each{|invitation| invitation.share_with!} invitations_to_me.each{|invitation| invitation.share_with!}
log_string << "success" log_hash[:status] = "success"
Rails.logger.info log_string Rails.logger.info log_hash
self.reload # Because to_request adds a request and saves elsewhere self.reload # Because to_request adds a request and saves elsewhere
self self
end end
rescue Exception => e rescue Exception => e
log_string << "failure" log_hash[:status] = "failure"
Rails.logger.info log_string Rails.logger.info log_hash
raise e raise e
end end
end end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter