text: from flask import session
  
  from app.log import get_logger
  from app.models.SQL_DB import User, db
  
  logger = get_logger(__name__)
  
  
  def edit_password(password):
      username = session["username"]
      user = User.query.filter_by(username=username).first()
      user.password = password
      return db.session.commit()
  
  
  def edit_profile(name_1, name_2, company, address):
      username = session["username"]
      user = User.query.filter_by(username=username).first()
      user.name_1 = name_1
      user.name_2 = name_2
      user.company = company
      user.address = address
      return db.session.commit()
  
  
  def edit_mg_settings(mg_domain, mg_api_private, mg_sender):
      username = session["username"]
      user = User.query.filter_by(username=username).first()
      user.mg_domain = mg_domain
      user.mg_api_private = mg_api_private
      user.mg_sender = mg_sender
      return db.session.commit()
  
  
  def get_user_ip():
      from flask import request
  
      try:
          user_ip = request.access_route[0]
      except Exception as inst:
          logger.exception(inst)
          user_ip = request.environ.get("HTTP_X_REAL_IP", request.remote_addr)
          logger.debug(f"Alternative IP: {user_ip}")
  
      return user_ip
  