Class: User::InvitesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/user/invites_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/user/invites_controller.rb', line 10

def create
  @send_sign_up_invite = SendSignUpInvite.new(params[:send_sign_up_invite])

  if @send_sign_up_invite.perform
    invite_email = UserPlane::InviteMailer.invite(@send_sign_up_invite.invite)
    invite_email.deliver_now
    
    redirect_to :new, notice: :success
  else
    render 'new'
  end      
end

#editObject



23
24
25
26
# File 'app/controllers/user/invites_controller.rb', line 23

def edit
  @sign_up_with_invite = SignUpWithInvite.new(code: params[:code])
  @sign_up_with_invite.email = @sign_up_with_invite.invite.recipient
end

#newObject



6
7
8
# File 'app/controllers/user/invites_controller.rb', line 6

def new
  @send_sign_up_invite = SendSignUpInvite.new
end

#oauth_callbackObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/user/invites_controller.rb', line 34

def oauth_callback
  # TODO: do I need to check the provider param? There is on in oauth_data
  # and one in params.
  oauth_data = request.env["omniauth.auth"]
  oauth_error = request.env["omniauth.error"]

  #FIXME: the way the user_name is inferred might work for facebook only
  oauth_params = {oauth_data: oauth_data,
                  oauth_error: oauth_error,
                  user_name: oauth_data[:info][:nickname],
                  code: params[:sign_up_with_invite_code]}
  # TODO: The host app should be able to do a sign_up here instead
  @sign_up_with_invite = SignUpWithInvite.new(oauth_params).(Identities::OAuth)

   @sign_up_with_invite
end

#updateObject



28
29
30
31
32
# File 'app/controllers/user/invites_controller.rb', line 28

def update
  @sign_up_with_invite = SignUpWithInvite.new().(Identities::Email)

   @sign_up_with_invite
end