Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
last changes_for_rubocop?..
Browse files Browse the repository at this point in the history
  • Loading branch information
6intez committed Jul 24, 2024
1 parent 8713609 commit a13cf8b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
21 changes: 1 addition & 20 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ def new
def create # rubocop:disable Metrics/AbcSize
unless user_signed_in?
response = Vk.exchange_code(params['code'], session[:code_verifier], params['device_id'], params['state'])
userid = response['user_id'].to_i

accesstoken = response['access_token']

refreshtoken = response['refresh_token']
deviceid = params['device_id']
state = params['state']
# поиск пользователя или создание его
user = User.user_create(response.merge({ deviceid: params['device_id'], state: params['state'],
expires_in: params['expires_in'] }))
Expand All @@ -34,7 +27,7 @@ def view # rubocop:disable Metrics/AbcSize
response_from_refresh = Vk.refresh_usertokens(current_user.refresh_token, current_user.user_device_id,
current_user.user_state)
current_user.update(access_token: response_from_refresh['access_token'],
refresh_token: response_from_refresh['refresh_token'], access_token_expiration_time: Time.current + params['expires_in'] )
refresh_token: response_from_refresh['refresh_token'], access_token_expiration_time: Time.current + params['expires_in'])
end
profile_data = Vk.get_profile_info(current_user)
@user_name = "#{profile_data['first_name']} #{profile_data['last_name']}"
Expand All @@ -43,16 +36,4 @@ def view # rubocop:disable Metrics/AbcSize
redirect_to root_path
end
end

# def needs_refresh_token?
# Time.now > current_user.access_token_expiration_time
# end
# def create_user(user_id,access_token,refresh_token,device_id,state)
# user = User.find_or_create_by(user_id: user_id) do |u|
# u.access_token = access_token
# u.refresh_token = refresh_token
# u.user_device_id = device_id
# u.access_token_expiration_time = Time.now + 55.minutes
# u.user_state = state
# end
end
2 changes: 0 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ def update_metrics_needed?
metrics_have_nil || post_metrics_have_nil
end



def password_required?
new_record? ? false : super
false
Expand Down

0 comments on commit a13cf8b

Please sign in to comment.