Class: FakeAuth::UsersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/fake_auth/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#becomeObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/fake_auth/users_controller.rb', line 8

def become
  @user = User.find params[:user_id]

  @user.access_tokens.destroy_all

  @user.access_tokens.create!({
    token: 'a-fake-auth-token',
    refresh_token: 'a-fake-auth-refresh-token',
    expires_at: Time.now + 1.year
  })

  session[:user_id] = @user.id

  redirect_to root_path
end

#indexObject



3
4
5
6
# File 'app/controllers/fake_auth/users_controller.rb', line 3

def index
  session[:user_id] = nil
  @users = User.all.limit(20)
end

#unbecomeObject



24
25
26
# File 'app/controllers/fake_auth/users_controller.rb', line 24

def unbecome
  redirect_to '/fake_auth'
end