initial work: add check for frist log in
This commit is contained in:
parent
6acf267a04
commit
f602ce0989
|
@ -95,6 +95,9 @@ class Travis::Api::App
|
||||||
# * **redirect_uri**: URI to redirect to after handshake.
|
# * **redirect_uri**: URI to redirect to after handshake.
|
||||||
get '/handshake' do
|
get '/handshake' do
|
||||||
handshake do |user, token, redirect_uri|
|
handshake do |user, token, redirect_uri|
|
||||||
|
|
||||||
|
check_first_login(@user)
|
||||||
|
|
||||||
if target_ok? redirect_uri
|
if target_ok? redirect_uri
|
||||||
content_type :html
|
content_type :html
|
||||||
data = { user: user, token: token, uri: redirect_uri }
|
data = { user: user, token: token, uri: redirect_uri }
|
||||||
|
@ -156,6 +159,13 @@ class Travis::Api::App
|
||||||
halt 403, "you are currently not allowed to perform this request. please contact support@travis-ci.com."
|
halt 403, "you are currently not allowed to perform this request. please contact support@travis-ci.com."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_first_login(user)
|
||||||
|
return if user.first_logged_in_at
|
||||||
|
puts "this is the first log in!!"
|
||||||
|
# user.update_attributes(first_logged_in_at: Time.now)
|
||||||
|
# #send event to customer.io
|
||||||
|
end
|
||||||
|
|
||||||
def serialize_user(user)
|
def serialize_user(user)
|
||||||
rendered = Travis::Api.data(user, version: :v2)
|
rendered = Travis::Api.data(user, version: :v2)
|
||||||
rendered['user'].merge('token' => user.tokens.first.try(:token).to_s)
|
rendered['user'].merge('token' => user.tokens.first.try(:token).to_s)
|
||||||
|
@ -224,18 +234,9 @@ class Travis::Api::App
|
||||||
super
|
super
|
||||||
|
|
||||||
@user = ::User.find_by_github_id(data['id'])
|
@user = ::User.find_by_github_id(data['id'])
|
||||||
check_first_login(@user)
|
|
||||||
# where is a user created if there is no user yet on our sytem
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_first_login(user)
|
|
||||||
return if user.first_logged_in_at
|
|
||||||
puts "this is the first log in!!"
|
|
||||||
# user.update_attributes(first_logged_in_at: Time.now)
|
|
||||||
# #send event to customer.io
|
|
||||||
end
|
|
||||||
|
|
||||||
def info(attributes = {})
|
def info(attributes = {})
|
||||||
info = data.to_hash.slice('name', 'login', 'gravatar_id')
|
info = data.to_hash.slice('name', 'login', 'gravatar_id')
|
||||||
info.merge! attributes.stringify_keys
|
info.merge! attributes.stringify_keys
|
||||||
|
|
Loading…
Reference in New Issue
Block a user