Method: Devise::Rownd::AuthController#update_data

Defined in:
app/controllers/devise/rownd/auth_controller.rb

#update_dataObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'app/controllers/devise/rownd/auth_controller.rb', line 48

def update_data
  Devise::Rownd::Log.debug('handling /update_data')

  request_body = JSON.parse request.body.read
  profile = {
    'data' => request_body['user_data']
  }
  new_user = Devise::Rownd::User.new(profile, session['warden.user.user.key'])

  Devise::Rownd::Log.debug("/update_data: instantiated user: #{new_user}")

  warden.set_user(new_user)

  Devise::Rownd::Log.debug('/update_data: set user in warden')

  # Remove the cached user profile data so that the next next time its accessed, it will be
  # fetched from the API Server
  cache_key = "rownd_user_#{new_user.data['user_id']}"
  Rails.cache.delete(cache_key)
  Devise::Rownd::Log.debug("/update_data: removed cache key: #{cache_key}")

  render json: {
    # should_refresh_page: true
  }, status: :ok
end