Class: Writefully::SessionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/writefully/sessions_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_wf_authorship!, #set_flash, #wf_authorship_signed_in?

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/writefully/sessions_controller.rb', line 9

def create
  @auth = Writefully.github_app.get_token(params[:code])
  @github = Github.new oauth_token: @auth.token
  @github_user = @github.users.get
  @owner  = find_or_create_owner 

  refresh_token
  session[:wf_authorship_id] = @owner.id
  redirect_to root_path, notice: 'signed_in'
end

#destroyObject



20
21
22
23
# File 'app/controllers/writefully/sessions_controller.rb', line 20

def destroy
  session[:wf_authorship_id] = nil
  redirect_to root_path, notice: 'signed_out'
end

#newObject



5
6
7
# File 'app/controllers/writefully/sessions_controller.rb', line 5

def new
  @github_app = Writefully.github_app
end