From f602ce09891c449178783df42cb444a06dfecc39 Mon Sep 17 00:00:00 2001 From: carlad Date: Thu, 3 Dec 2015 12:52:34 +0100 Subject: [PATCH] initial work: add check for frist log in --- lib/travis/api/app/endpoint/authorization.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/travis/api/app/endpoint/authorization.rb b/lib/travis/api/app/endpoint/authorization.rb index 456ac0e8..1084727e 100644 --- a/lib/travis/api/app/endpoint/authorization.rb +++ b/lib/travis/api/app/endpoint/authorization.rb @@ -95,6 +95,9 @@ class Travis::Api::App # * **redirect_uri**: URI to redirect to after handshake. get '/handshake' do handshake do |user, token, redirect_uri| + + check_first_login(@user) + if target_ok? redirect_uri content_type :html 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." 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) rendered = Travis::Api.data(user, version: :v2) rendered['user'].merge('token' => user.tokens.first.try(:token).to_s) @@ -224,18 +234,9 @@ class Travis::Api::App super @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 - 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 = {}) info = data.to_hash.slice('name', 'login', 'gravatar_id') info.merge! attributes.stringify_keys