satnet-project / server

Repository with the source code for the server of the SATNet network.
Apache License 2.0
2 stars 1 forks source link

Can't log in with superuser #26

Closed crespum closed 9 years ago

crespum commented 9 years ago

After a clean installation I cant log in to SatNet with the username/password created with createsuperuser. The steps I follow are:

./server-setup.sh -a
python manage.py migrate
python manage.py createsuperuser

The message I obtain is after trying to log in is The e-mail address and/or password you specified are not correct.

Furthermore, if I try to create a new user using the web interface I get the following error:

Environment:

Request Method: POST
Request URL: http://localhost:8000/accounts/signup/

Django Version: 1.7.4
Python Version: 3.4.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'user_sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'allauth',
 'allauth.account',
 'session_security',
 'periodically',
 'rpc4django',
 'django_extensions',
 'datetimewidget',
 'django_nose',
 'services.accounts',
 'services.configuration',
 'services.scheduling',
 'services.communications',
 'services.simulation',
 'services.leop',
 'services.network',
 'django.contrib.admin')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'user_sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.RemoteUserMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'session_security.middleware.SessionSecurityMiddleware')

Traceback:
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
  111.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/django/views/generic/base.py" in view
  69.             return self.dispatch(request, *args, **kwargs)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/django/utils/decorators.py" in _wrapper
  29.             return bound_func(*args, **kwargs)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
  76.             return view(request, *args, **kwargs)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/django/utils/decorators.py" in bound_func
  25.                 return func.__get__(self, type(self))(*args2, **kwargs2)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/allauth/account/views.py" in dispatch
  169.         return super(SignupView, self).dispatch(request, *args, **kwargs)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/allauth/account/views.py" in dispatch
  66.                                             **kwargs)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/allauth/account/views.py" in dispatch
  147.                                                           **kwargs)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/django/views/generic/base.py" in dispatch
  87.         return handler(request, *args, **kwargs)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/allauth/account/views.py" in post
  82.             response = self.form_valid(form)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/allauth/account/views.py" in form_valid
  182.         user = form.save(self.request)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/allauth/account/forms.py" in save
  304.         self.custom_signup(request, user)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/allauth/account/forms.py" in custom_signup
  266.             custom_form.signup(request, user)
File "/home/crespum/SATNET/server/services/accounts/forms.py" in signup
  108.         profile.save()
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/django/db/models/base.py" in save
  589.                        force_update=force_update, update_fields=update_fields)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/django/db/models/base.py" in save_base
  616.                 self._save_parents(cls, using, update_fields)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/django/db/models/base.py" in _save_parents
  641.             self._save_table(cls=parent, using=using, update_fields=update_fields)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/django/db/models/base.py" in _save_table
  679.                                       forced_update)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/django/db/models/base.py" in _do_update
  723.         return filtered._update(values) > 0
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/django/db/models/query.py" in _update
  600.         return query.get_compiler(self.db).execute_sql(CURSOR)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py" in execute_sql
  1004.         cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py" in execute_sql
  786.             cursor.execute(sql, params)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/django/db/backends/utils.py" in execute
  81.             return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/django/db/backends/utils.py" in execute
  65.                 return self.cursor.execute(sql, params)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/django/db/utils.py" in __exit__
  94.                 six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/django/utils/six.py" in reraise
  658.             raise value.with_traceback(tb)
File "/home/crespum/SATNET/server/.venv/lib/python3.4/site-packages/django/db/backends/utils.py" in execute
  65.                 return self.cursor.execute(sql, params)

Exception Type: IntegrityError at /accounts/signup/
Exception Value: duplicate key value violates unique constraint "auth_user_username_key"
DETAIL:  Key (username)=() already exists.
rtubio commented 9 years ago

After installation, once you create the superuser, you have to validate your email. For that, it is necessary that, right after everything has been set up by the installation script, you have to run the server and log in with the superuser credentials at the main interface.

Once you log in, the system should automatically send you an email to validate your email address.

Have you already tried this?

crespum commented 9 years ago

Yes. That is exactly what I do. Is it possible that secrets/email.py is wrong but I am not seeing any error message?

rtubio commented 9 years ago

Check that in "secrets/email.py" you have the following configuration:

EMAIL_USE_TLS = True
# EMAIL_FILE_PATH = '/tmp/email-messages/'

... with "EMAIL_USE_TLS = True" and the "EMAIL_FILE_PATH" variable commented or absent.

sgongar commented 9 years ago

I confirm that I have the same mistakes. The system doesn't allow me to log into my account.

When I tried to create a new user through the web interface I get a duplicate key error.

rtubio commented 9 years ago

Yes, apparently this is a problem that I already found out for a commit in the unsecure_3k branch but that I thought that it will not affect to the main development_3k branch:

https://github.com/satnet-project/server/commit/b29648f6cf79c2c8fd08ebe8954009d2de97b44b

I have also posted this issue in Stackoverflow:

http://stackoverflow.com/questions/30604423/inheritance-in-django-child-class-updates-parent-with-empty-fields

I will fix it right away for the main branch.

rtubio commented 9 years ago

The last push should have solved this issue. I have a clean installation up and working in a virtual machine now.

Please let me know if the update works.

crespum commented 9 years ago

Now it looks like the server tries to send a confirmation email but it never arrives. I don't see any error message in the terminal. In the browser I see We have sent an e-mail to you for verification. Follow the link provided to finalize the signup process. Please contact us if you do not receive it within a few minutes.

sgongar commented 9 years ago

When I logged with my credentials the system gave me an authentication error. After a quick find I found that Google had rejected the connection due to a security issue.

When I reduced the security level of my account at this website, https://www.google.com/settings/security/lesssecureapps, the error disappeared.

crespum commented 9 years ago

It works now. Be careful to use smtp.gmail.com instead of smtp.google.com at secrets/email.py

rtubio commented 9 years ago

To be honest, this error appeared after migrating everything to Python 3.3 and Django 1.7. I still have not identified which one of the migrations was the real cause, but with Python 2.7 and Django < 1.7 this was not happening... I expected a better answer to my Stack Overflow issue (http://stackoverflow.com/questions/30604423/inheritance-in-django-child-class-updates-parent-with-empty-fields), but nobody ever gave me a more detailed explanation. Apparently, it is the way it works.