app/controllers/users_controller.rb
# delete user data and close account (ajax request)
delete user data and close account (ajax request)
delete user data and close account ( ajax request )
def destroy
    @trigger_tasks_form = false
    table = 'tasks_errors'
    begin
      return format_response_key '.not_logged_in' unless logged_in?
      id = params[:id]
      user = User.find_by_id(id)
      if !user
        logger.debug2 "invalid request. User with id #{id} was not found"
        return format_response_key '.invalid_request'
      end
      logger.debug2 "user2 = #{user.debug_info}"
      if !login_user_ids.index(user.user_id)
        logger.debug2 "invalid request. Not logged in with user id #{id}"
        return format_response_key '.not_logged_in'
      end
      if !user.deleted_at
        user.update_attribute(:deleted_at, Time.new)
        other_user = @users.find { |u| u.id != user.id and !u.deleted_at }
        add_task "User.delete_user(#{user.id})", 5
        @trigger_tasks_form = true
        key = other_user ? '.ok2_html' : '.ok1_html'
        return format_response_key key, user.app_and_apiname_hash.merge(:url => API_APP_SETTING_URL[user.provider] || '#')
      end
      if user.deleted_at > 6.minutes.ago
        return format_response_key '.pending_html', user.app_and_apiname_hash.merge(:url => API_APP_SETTING_URL[user.provider] || '#')
      end
      key, options = User.delete_user(user.id)
      return format_response_key(key, options) if key
      logout(user.provider)
      format_response_key '.completed_html', user.app_and_apiname_hash.merge(:url => API_APP_SETTING_URL[user.provider] || '#')
    rescue => e
      logger.debug2 "Exception: #{e.message.to_s}"
      logger.debug2 "Backtrace: " + e.backtrace.join("\n")
      format_response_key ".exception", :error => e.message.to_s
    end
  end
def destroy @trigger_tasks_form = false table = 'tasks_errors' begin return format_response_key '.not_logged_in' unless logged_in? id = params [ :id ] user = User . find_by_id ( id ) if ! user logger . debug2 "invalid request. User with id #{id} was not found" return format_response_key '.invalid_request' end logger . debug2 "user2 = #{user.debug_info}" if ! login_user_ids . index ( user . user_id ) logger . debug2 "invalid request. Not logged in with user id #{id}" return format_response_key '.not_logged_in' end if ! user . deleted_at user . update_attribute ( :deleted_at , Time . new ) other_user = @users . find { | u | u . id != user . id and ! u . deleted_at } add_task "User.delete_user(#{user.id})" , 5 @trigger_tasks_form = true key = other_user ? '.ok2_html' : '.ok1_html' return format_response_key key , user . app_and_apiname_hash . merge ( :url => API_APP_SETTING_URL [ user . provider ] || '#' ) end if user . deleted_at > 6 . minutes . ago return format_response_key '.pending_html' , user . app_and_apiname_hash . merge ( :url => API_APP_SETTING_URL [ user . provider ] || '#' ) end key , options = User . delete_user ( user . id ) return format_response_key ( key , options ) if key logout ( user . provider ) format_response_key '.completed_html' , user . app_and_apiname_hash . merge ( :url => API_APP_SETTING_URL [ user . provider ] || '#' ) rescue => e logger . debug2 "Exception: #{e.message.to_s}" logger . debug2 "Backtrace: " + e . backtrace . join ( "\n" ) format_response_key ".exception" , :error => e . message . to_s end end
delete user data and close account (ajax request)
delete user data and close account ( ajax request )
# check user.id # delete mark user and schedule logical delete task # wait - waiting for logical and physical delete # physical delete user now (is normally done in util.new_messages_count) # delete ok