deepfence / ThreatMapper

Open Source Cloud Native Application Protection Platform (CNAPP)
https://deepfence.io
Apache License 2.0
4.72k stars 569 forks source link

Email User Invite not working #790

Open wonhee0410 opened 1 year ago

wonhee0410 commented 1 year ago

Describe the bug When I invite a user via email, this feature is not working.

To Reproduce Steps to reproduce the behavior:

  1. Go to User Management
  2. Click on Send Invite
  3. Fill in email
  4. Click Send sign up request

Expected behavior It shows "Invite sent" but no email has been received.

Screenshots image

Components/Services affected

Additional context

Log file of this:
`      #Traceback (most recent call last):
      U  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2077, in wsgi_app
      ,    response = self.full_dispatch_request()
      b  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1525, in full_dispatch_request
      '    rv = self.handle_user_exception(e)
      e  File "/usr/local/lib/python3.9/site-packages/flask_restful/__init__.py", line 271, in error_router
          return original_handler(e)
      e  File "/usr/local/lib/python3.9/site-packages/flask_restful/__init__.py", line 271, in error_router
          return original_handler(e)
      g  File "/usr/local/lib/python3.9/site-packages/flask_cors/extension.py", line 165, in wrapped_function
      E    return cors_after_request(app.make_response(f(*args, **kwargs)))
      b  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1523, in full_dispatch_request
      !    rv = self.dispatch_request()
      ]  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1509, in dispatch_request
      Q    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
      n  File "/usr/local/lib/python3.9/site-packages/flask_jwt_extended/view_decorators.py", line 154, in decorator
      8    return current_app.ensure_sync(fn)(*args, **kwargs)
      A  File "/app/code/utils/decorators.py", line 30, in func_wrapper
      !    return func(*args, **kwargs)
      =  File "/app/code/api/user_api.py", line 602, in user_delete
          user.delete()
      6  File "/app/code/models/user.py", line 87, in delete
          db.session.commit()
      %  File "<string>", line 2, in commit
      `  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 1435, in commit
      3    self._transaction.commit(_to_root=self.future)
      _  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 829, in commit
          self._prepare_impl()
      f  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 808, in _prepare_impl
          self.session.flush()
      _  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 3367, in flush
          self._flush(objects)
      `  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 3507, in _flush
      2    transaction.rollback(_capture_exception=True)
      e  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
          compat.raise_(
      _  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
          raise exception
      `  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 3467, in _flush
          flush_context.execute()
      c  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/unitofwork.py", line 456, in execute
          rec.execute(self)
      c  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/unitofwork.py", line 630, in execute
      -    util.preloaded.orm_persistence.save_obj(
      e  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/persistence.py", line 237, in save_obj
          _emit_update_statements(
      u  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/persistence.py", line 1001, in _emit_update_statements
           c = connection._execute_20(
      e  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1631, in _execute_20
      G    return meth(self, args_10style, kwargs_10style, execution_options)
      p  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/elements.py", line 325, in _execute_on_connection
      .    return connection._execute_clauseelement(
      p  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1498, in _execute_clauseelement
      !    ret = self._execute_context(
      j  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1862, in _execute_context
      "    self._handle_dbapi_exception(
      q  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 2043, in _handle_dbapi_exception
          util.raise_(
      _  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
          raise exception
      j  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1819, in _execute_context
          self.dialect.do_execute(
      f  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 732, in do_execute
      *    cursor.execute(statement, parameters)
      “sqlalchemy.exc.IntegrityError: (psycopg2.errors.NotNullViolation) null value in column "user_id" of relation "invite" violates not-null constraint
      ±DETAIL:  Failing row contains (1, huydq2@xmail.com, 8e62d44ba153c5824aa73acbc9335768, null, 1, 1, t, 2022-08-23 07:43:27.472741+00, 2022-12-29 10:18:45.733978+00).
      
      _[SQL: UPDATE invite SET user_id=%(user_id)s, updated_at=now() WHERE invite.id = %(invite_id)s]
      0[parameters: {'user_id': None, 'invite_id': 1}]
      =(Background on this error at: https://sqlalche.me/e/14/gkpj)
shyam-dev commented 1 year ago

Hello - You need to configure a SMTP server so that the platform can send emails.

Settings->Email Configuration will help.

Thanks

wonhee0410 commented 1 year ago

Hello - You need to configure a SMTP server so that the platform can send emails.

Settings->Email Configuration will help.

Thanks

But I've configured SMTP Server. image

mukuldeepfence commented 1 year ago

@wonhee0410 can you please try following steps -

  1. Delete existing email configuration
  2. Logout and login again
  3. Setup email configuration
  4. Now try to invite the user once again

Note - latest tag release is 1.4.2