Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cleaning-portalmec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Richard Fernando Heise Ferreira
cleaning-portalmec
Commits
a7ba9a34
Commit
a7ba9a34
authored
9 years ago
by
Mauricio Giacomini Girardello
Browse files
Options
Downloads
Patches
Plain Diff
remove old routes and adding devise CORS support
parent
d809296c
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/controllers/application_controller.rb
+1
-5
1 addition, 5 deletions
app/controllers/application_controller.rb
config/application.rb
+11
-0
11 additions, 0 deletions
config/application.rb
config/routes.rb
+3
-87
3 additions, 87 deletions
config/routes.rb
with
15 additions
and
92 deletions
app/controllers/application_controller.rb
+
1
−
5
View file @
a7ba9a34
class
ApplicationController
<
ActionController
::
API
class
ApplicationController
<
ActionController
::
API
include
DeviseTokenAuth
::
Concerns
::
SetUserByToken
include
Pundit
include
Pundit
# 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: :null_session
# protect_from_forgery with: :null_session
before_action
:count_learning_objects
before_action
:configure_permitted_parameters
,
if: :devise_controller?
before_action
:configure_permitted_parameters
,
if: :devise_controller?
rescue_from
Pundit
::
NotAuthorizedError
,
with: :user_not_authorized
rescue_from
Pundit
::
NotAuthorizedError
,
with: :user_not_authorized
protected
protected
def
count_learning_objects
@learning_object_count
=
LearningObject
.
count
end
def
configure_permitted_parameters
def
configure_permitted_parameters
registration_params
=
[
:name
,
:email
,
:avatar
,
:password
,
:password_confirmation
]
registration_params
=
[
:name
,
:email
,
:avatar
,
:password
,
:password_confirmation
]
...
...
This diff is collapsed.
Click to expand it.
config/application.rb
+
11
−
0
View file @
a7ba9a34
...
@@ -46,6 +46,17 @@ module Portalmec
...
@@ -46,6 +46,17 @@ module Portalmec
# end
# end
# end
# end
config
.
middleware
.
use
Rack
::
Cors
do
allow
do
origins
'*'
resource
'*'
,
:headers
=>
:any
,
:expose
=>
[
'access-token'
,
'expiry'
,
'token-type'
,
'uid'
,
'client'
],
:methods
=>
[
:get
,
:post
,
:options
,
:delete
,
:put
]
end
end
# default language
# default language
config
.
i18n
.
default_locale
=
'pt-BR'
.
to_sym
config
.
i18n
.
default_locale
=
'pt-BR'
.
to_sym
...
...
This diff is collapsed.
Click to expand it.
config/routes.rb
+
3
−
87
View file @
a7ba9a34
Rails
.
application
.
routes
.
draw
do
Rails
.
application
.
routes
.
draw
do
require
'sidekiq/web'
require
'sidekiq/web'
devise_for
:users
,
:controllers
=>
{
:omniauth_callbacks
=>
"callbacks"
}
# devise_for :users, :controllers => { :omniauth_callbacks => "callbacks" }
namespace
:v1
do
namespace
:auth
do
mount_devise_token_auth_for
'User'
,
skip:
[
:omniauth_callbacks
],
at: :auth
mount_devise_token_auth_for
'User'
,
skip:
[
:omniauth_callbacks
]
end
root
'welcome#index'
resource
:feedback
,
only:
[
:create
,
:new
]
do
get
:new_bug
post
:report_bug
end
resources
:subjects
,
only:
[
:index
,
:show
]
resource
:complaints
,
only:
[
'create'
]
resources
:institutions
do
member
do
get
:users
end
end
resources
:learning_objects
do
resources
:build
,
controller:
'learning_objects/build'
get
:reviews
,
to:
'reviews#list'
,
as:
'reviews'
member
do
post
:like
get
:collections
get
:upload
get
:download
end
end
# file upload routes
resource
:chunk
,
only:
[
:create
,
:show
]
get
'/collections/me'
=>
'collections#me'
,
as:
'collections_me'
resources
:collections
do
get
:reviews
,
to:
'reviews#list'
,
as:
'reviews'
member
do
# collection list
get
:list
# change privacy
post
:change_privacy
# add/remove a learning object for some collection
post
'/learning_objects/:learning_objects_ids'
,
as: :add_learning_object
,
action: :add_learning_object
delete
'/learning_objects/:learning_objects_ids'
,
as: :remove_learning_object
,
action: :remove_learning_object
end
end
resources
:reviews
,
except: :index
do
member
do
post
:rate
end
end
end
get
'/bookmarks'
=>
'bookmarks#show'
,
as:
'bookmark'
get
'/bookmarks/list'
=>
'bookmarks#list'
,
as:
'list'
post
'/bookmarks/:type/:id'
=>
'bookmarks#add_object'
,
as: :bookmark_add
delete
'/bookmarks/:type/:id'
=>
'bookmarks#remove_object'
,
as: :bookmark_remove
get
'/users/verify_email'
=>
'users#verify_email'
,
as: :verify_email
get
'/users/list'
=>
'users#list'
,
as: :list_all_users
resources
:users
,
only:
[
:show
]
do
member
do
post
'/follow/:followable_type/:followable_id'
=>
'users#follow'
,
as: :follow
post
'/unfollow/:followable_type/:followable_id'
=>
'users#unfollow'
,
as: :unfollow
end
end
get
'/terms_of_service'
=>
'welcome#terms_of_service'
,
as:
'terms_of_service'
get
'/about'
=>
'about#index'
,
as:
'about'
get
'/links'
=>
'links#index'
,
as:
'links'
get
'/search'
=>
'search#index'
,
as:
'search'
get
'/search/fetch'
=>
'search#fetch'
,
as:
'search_fetch'
get
'/autocomplete'
=>
'search#autocomplete'
get
'/search/get_class_size'
=>
'search#get_class_size'
,
as: :get_class_size
get
'/subject/:id'
=>
'welcome#subject'
,
as:
'subject_index'
get
'/add_file'
=>
'welcome#add_file'
get
'/signup'
=>
'welcome#signup'
get
'/follow_collection'
=>
'welcome#follow_collection'
get
'/file_outside_user'
=>
'welcome#file_outside_user'
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment