Commit 21bcff06 by John Doe

working on interface controller

parent 4f5e0f72
......@@ -72,7 +72,7 @@ end
group :development do
gem 'guard-rubocop'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
gem 'web-console'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
......
class InterfacesController < ActionController::Base
before_action :authenticate_interface_user!, except: [:authenticate]
#GET /authenticate
def authenticate
token = InterfaceAuthToken.find(params[:token])
#check if token timestamp is valid
puts("this session is: #{session[:test]}")
#sign_in(User.first)
reset_session
session[:user_id]=token.user.id
session[:interface_id]=token.joule_module.id
#interface_user_session(interface: token.interface.id)
#redirect '/'
end
#GET /logout
def logout
interface_user_sign_out
end
#everything else is proxied
private
def authenticate_interface_user!
puts 'authenticating...'
end
end
class InterfaceAuthToken < ApplicationRecord
end
......@@ -31,6 +31,9 @@ module ControlPanel
# Middleware like session, flash, cookies can be added back manually.
# Skip views, helpers and assets when generating a new resource.
config.api_only = true
# but still support cookies for interfaces
config.middleware.use ActionDispatch::Cookies
config.middleware.use ActionDispatch::Session::CookieStore
# Add folders under the services and adapters directory
%w(data nilm db db_folder db_stream permission user_group user data_view joule_modules).each do |service|
config.autoload_paths << Rails.root.join("app/services/#{service}")
......
......@@ -44,4 +44,6 @@ Rails.application.routes.draw do
put 'invite_user'
end
end
get 'interfaces/authenticate', to: 'interfaces#authenticate'
end
class CreateInterfaceAuthTokens < ActiveRecord::Migration[5.1]
def change
create_table :interface_auth_tokens do |t|
t.timestamps
end
end
end
require 'rails_helper'
RSpec.describe InterfacesController, type: :controller do
end
FactoryGirl.define do
factory :interface_auth_token do
end
end
require 'rails_helper'
RSpec.describe InterfaceAuthToken, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment