fake sign in
This commit is contained in:
parent
a8fc2f0e7a
commit
3387c185fa
|
@ -15,7 +15,12 @@ class Travis::Api::App
|
||||||
|
|
||||||
def service(key)
|
def service(key)
|
||||||
const = Travis.services[key] || raise("no service registered for #{key}")
|
const = Travis.services[key] || raise("no service registered for #{key}")
|
||||||
const.new(respond_to?(:current_user) ? current_user : nil)
|
const.new(current_user)
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_user
|
||||||
|
# TODO
|
||||||
|
User.where(:login => 'svenfuchs').first
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ class Travis::Api::App
|
||||||
class Branches < Endpoint
|
class Branches < Endpoint
|
||||||
# TODO: Add documentation.
|
# TODO: Add documentation.
|
||||||
get('/') do
|
get('/') do
|
||||||
body service(:branches).find_all(params), :type => :branches
|
body service(:branches).find_all(params), type: :branches
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,8 +5,9 @@ class Travis::Api::App
|
||||||
# TODO: Add documentation.
|
# TODO: Add documentation.
|
||||||
class Hooks < Endpoint
|
class Hooks < Endpoint
|
||||||
# TODO: Add implementation and documentation.
|
# TODO: Add implementation and documentation.
|
||||||
get('/', scope: :private) do
|
# TODO scope: :private
|
||||||
body service(:builds).find_all(params)
|
get('/') do
|
||||||
|
body service(:hooks).find_all(params), type: :hooks
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Add implementation and documentation.
|
# TODO: Add implementation and documentation.
|
||||||
|
|
|
@ -18,10 +18,45 @@ class Travis::Api::App
|
||||||
# "synced_at": "2012-08-14T22:11:21Z"
|
# "synced_at": "2012-08-14T22:11:21Z"
|
||||||
# }
|
# }
|
||||||
# }
|
# }
|
||||||
get('/', scope: :private) { body(user) }
|
get '/', scope: :private do
|
||||||
|
body user
|
||||||
|
end
|
||||||
|
|
||||||
|
put '/', scope: :private do
|
||||||
|
raise NotImplementedError
|
||||||
|
update_locale if valid_locale?
|
||||||
|
'ok'
|
||||||
|
end
|
||||||
|
|
||||||
# TODO: Add implementation and documentation.
|
# TODO: Add implementation and documentation.
|
||||||
post('/sync', scope: :private) { raise NotImplementedError }
|
post '/sync', scope: :private do
|
||||||
|
raise NotImplementedError
|
||||||
|
sync_user(current_user)
|
||||||
|
'ok'
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def sync_user(user)
|
||||||
|
unless user.is_syncing?
|
||||||
|
publisher = Travis::Amqp::Publisher.new('sync.user')
|
||||||
|
publisher.publish({ user_id: user.id }, type: 'sync')
|
||||||
|
user.update_column(:is_syncing, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def locale
|
||||||
|
params[:user][:locale]
|
||||||
|
end
|
||||||
|
|
||||||
|
def valid_locale?
|
||||||
|
I18n.available_locales.include?(locale.to_sym) # ???
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_locale
|
||||||
|
current_user.update_attributes!(:locale => locale.to_s)
|
||||||
|
session[:locale] = locale # ???
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user