-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
408 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class ApiController < ActionController::Base | ||
include DeviseTokenAuth::Concerns::SetUserByToken | ||
protect_from_forgery with: :null_session | ||
|
||
before_filter :set_locale | ||
before_action :set_client_info | ||
|
||
|
||
private | ||
def set_locale | ||
begin | ||
I18n.locale = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first unless request.env['HTTP_ACCEPT_LANGUAGE'].nil? | ||
rescue | ||
logger.error 'Invalid locale. HTTP_ACCEPT_LANGUAGE = ' + request.env['HTTP_ACCEPT_LANGUAGE'].to_s | ||
end | ||
end | ||
|
||
def set_client_info | ||
@client_platform = @client_version = nil | ||
begin | ||
unless request.headers['Client-Version'].blank? | ||
@client_platform, @client_version = request.headers['Client-Version'].split('/') | ||
end | ||
rescue | ||
logger.error 'Bad Client-Version header provided by client: ' + request.env['Client-Version'] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
DeviseTokenAuth.setup do |config| | ||
# By default the authorization headers will change after each request. The | ||
# client is responsible for keeping track of the changing tokens. Change | ||
# this to false to prevent the Authorization header from changing after | ||
# each request. | ||
#config.change_headers_on_each_request = true | ||
|
||
# By default, users will need to re-authenticate after 2 weeks. This setting | ||
# determines how long tokens will remain valid after they are issued. | ||
config.token_lifespan = 15.days | ||
|
||
# Sometimes it's necessary to make several requests to the API at the same | ||
# time. In this case, each request in the batch will need to share the same | ||
# auth token. This setting determines how far apart the requests can be while | ||
# still using the same auth token. | ||
#config.batch_request_buffer_throttle = 5.seconds | ||
|
||
# This route will be the prefix for all oauth2 redirect callbacks. For | ||
# example, using the default '/omniauth', the github oauth2 provider will | ||
# redirect successful authentications to '/omniauth/github/callback' | ||
#config.omniauth_prefix = "/omniauth" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.