Skip to content
Snippets Groups Projects
Commit 570708f7 authored by Mauricio Giacomini Girardello's avatar Mauricio Giacomini Girardello
Browse files

Merge branch 'master' of gitlab.c3sl.ufpr.br:portalmec/portalmec

parents c241c4ff 5c72aaec
No related branches found
No related tags found
No related merge requests found
...@@ -22,7 +22,7 @@ gem 'jbuilder', '~> 2.0' ...@@ -22,7 +22,7 @@ gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password # Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7' gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server # Use Unicorn as the app server
# gem 'unicorn' # gem 'unicorn'
...@@ -56,7 +56,10 @@ end ...@@ -56,7 +56,10 @@ end
# authentication # authentication
gem 'devise' gem 'devise'
# enable login via rest
gem 'devise_token_auth' gem 'devise_token_auth'
gem 'rack-cors', require: 'rack/cors'
#bootstrap #bootstrap
gem 'bootstrap-sass' gem 'bootstrap-sass'
......
...@@ -152,6 +152,7 @@ GEM ...@@ -152,6 +152,7 @@ GEM
procto (0.0.2) procto (0.0.2)
puma (2.13.4) puma (2.13.4)
rack (1.6.4) rack (1.6.4)
rack-cors (0.4.0)
rack-test (0.6.3) rack-test (0.6.3)
rack (>= 1.0) rack (>= 1.0)
rails (4.2.0) rails (4.2.0)
...@@ -263,6 +264,7 @@ PLATFORMS ...@@ -263,6 +264,7 @@ PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
bcrypt (~> 3.1.7)
better_errors better_errors
bootstrap-sass bootstrap-sass
byebug byebug
...@@ -280,6 +282,7 @@ DEPENDENCIES ...@@ -280,6 +282,7 @@ DEPENDENCIES
orientdb4r orientdb4r
pg pg
puma puma
rack-cors
rails (= 4.2.0) rails (= 4.2.0)
rmagick rmagick
rubycritic rubycritic
......
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
include DeviseTokenAuth::Concerns::SetUserByToken
# Prevent CSRF attacks by raising an exception. # Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead. # For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception protect_from_forgery with: :null_session
include DeviseTokenAuth::Concerns::SetUserByToken
def repository def repository
Portalmec::Application.repository Portalmec::Application.repository
......
...@@ -32,5 +32,18 @@ module Portalmec ...@@ -32,5 +32,18 @@ module Portalmec
Repository::Environments.fetch Rails.env Repository::Environments.fetch Rails.env
end end
# CORS for login via rest
# config.middleware.use Rack::Cors do
config.middleware.insert_before 0, "Rack::Cors", :debug => true, :logger => (-> { Rails.logger }) do
allow do
origins '*'
# TODO: change when mobile app is done
resource '/auth/*',
headers: :any,
expose: ['access-token', 'expiry', 'token-type', 'uid', 'client'],
methods: [:get, :post, :options, :delete, :put]
end
end
end end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment