Class: Notee::TokensController

Inherits:
ApplicationController show all
Defined in:
app/controllers/notee/tokens_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /tokens



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/notee/tokens_controller.rb', line 13

def create
  if Notee.notee_id == params[:id] && Notee.notee_password == params[:password]
    if token = Token.create!
      session[:access_token] = token.access_token
      return redirect_to root_path
    end
  end

  if now_user = User.(params[:id], params[:password])
    if token = Token.create!(user_id: now_user.id)
      session[:access_token] = token.access_token
    end
  end

  redirect_to root_path
end

#destroyObject

DELETE /tokens/1



31
32
33
34
# File 'app/controllers/notee/tokens_controller.rb', line 31

def destroy
  Token.find_by_access_token(session[:access_token]).destroy!
  session.delete(:access_token)
end

#newObject

GET /tokens/new



9
10
# File 'app/controllers/notee/tokens_controller.rb', line 9

def new
end