hipster-philology / pyrrha

A language-independent post-correction app for POS-tagging and lemmatization
https://pyrrha.huma-num.fr
MIT License
27 stars 16 forks source link

CLI command for activating users and making them admin #167

Closed PonteIneptique closed 5 months ago

PonteIneptique commented 4 years ago

Is your feature request related to a problem? Please describe.

Playing with Pyrrha localy, there is no real way to activate users or making them admin without going into the database. We should have a CLI command to make that simpler.

Describe the solution you'd like

python manage.py edit-user $user-id --activate --set-admin

Describe alternatives you've considered

First option was to disable mail activation, but honnestly, that would be more cumbersome.

jhrdt commented 3 years ago

Hej,

I would like to give it a try.

What does activate mean? Is it the same as confirmed (registration + email confirmation) ?

PonteIneptique commented 3 years ago

Hi! Yes, it is :) Basically, some people like to use this software locally and, as a general consequence, cannot setup a mail server to receive confirmation mail. The idea would be to confirm account through the CLI, with the option to turn them into admin. :) Tell me if I can provide you with more pointers :)

Le lun. 5 oct. 2020 à 11:41 PM, jhrdt notifications@github.com a écrit :

Hej,

I would like to give it a try.

What does activate mean? Is it the same as confirmed (registration + email confirmation) ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hipster-philology/pyrrha/issues/167#issuecomment-703904684, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOXEZSE2F7ZGB63MKDQLN3SJI4RNANCNFSM4MFLCSRQ .

PonteIneptique commented 3 years ago

The CLI is there by the way : https://github.com/hipster-philology/pyrrha/blob/dev/app/cli.py

jhrdt commented 3 years ago

I also encountered the issue, that the software is not usable without a smtp sever.

I resolved this with python -m smtpd -n -c DebuggingServer localhost:1025 and using the following config

    MAIL_SERVER = 'localhost'
    MAIL_PORT = 1025
    MAIL_USE_TLS = False
    MAIL_USE_SSL = False
    MAIL_USERNAME = ''
    MAIL_PASSWORD = ''

Nevermind, when there is an edit-user command, the user have to be already present.

The user is created during registration (or is there another way?). So the smtp is still required, due to the fact that the user gets his first confirmation email, when the first registration is completed.

PonteIneptique commented 3 years ago

Hmm, thanks for the info. So you are saying the registration does not go through ? If so, I might have to create a flag which prevent mail sending :)

jhrdt commented 3 years ago

Hmm, thanks for the info. So you are saying the registration does not go through ?

The registration works, but the app throws a exception.

send: 'ehlo [127.0.1.1]\r\n'
reply: b'250-smtp-out-n06.prod.us-west-2.postgun.com\r\n'
reply: b'250-AUTH PLAIN LOGIN\r\n'
reply: b'250-SIZE 52428800\r\n'
reply: b'250-8BITMIME\r\n'
reply: b'250-SMTPUTF8\r\n'
reply: b'250 PIPELINING\r\n'
reply: retcode (250); Msg: b'smtp-out-n06.prod.us-west-2.postgun.com\nAUTH PLAIN LOGIN\nSIZE 52428800\n8BITMIME\nSMTPUTF8\nPIPELINING'
send: 'AUTH PLAIN AHBvc3RtYXN0ZXJAc2FuZGJveGZhN2E4NzMzMDNjMTQyNWY4ZmRhNzk0N2FhMTk1Njk2Lm1haWxndW4ub3JnAGMzYzdjYzNjNzg1ODE1YTg3MjhhNjI2Njc0NWE3MGRiLWI2MTgzYWQ0LWM3OGQ3NDg3\r\n'
reply: b'535 Authentication failed\r\n'
reply: retcode (535); Msg: b'Authentication failed'
send: 'AUTH LOGIN cG9zdG1hc3RlckBzYW5kYm94ZmE3YTg3MzMwM2MxNDI1ZjhmZGE3OTQ3YWExOTU2OTYubWFpbGd1bi5vcmc=\r\n'
Exception in thread Thread-20:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/tmp/gh/pyrrha/app/email.py", line 17, in _async
    mail.send(msg)
  File "/tmp/gh/pyrrha/venv/lib/python3.8/site-packages/flask_mail.py", line 491, in send
    with self.connect() as connection:
  File "/tmp/gh/pyrrha/venv/lib/python3.8/site-packages/flask_mail.py", line 144, in __enter__
    self.host = self.configure_host()
  File "/tmp/gh/pyrrha/venv/lib/python3.8/site-packages/flask_mail.py", line 165, in configure_host
    host.login(self.mail.username, self.mail.password)
  File "/usr/lib/python3.8/smtplib.py", line 723, in login
    (code, resp) = self.auth(
  File "/usr/lib/python3.8/smtplib.py", line 635, in auth
    (code, resp) = self.docmd("AUTH", mechanism + " " + response)
  File "/usr/lib/python3.8/smtplib.py", line 425, in docmd
    return self.getreply()
  File "/usr/lib/python3.8/smtplib.py", line 398, in getreply
    raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed
PonteIneptique commented 3 years ago

Ok. I am gonna open an issue to avoid the crash. If you are still willing to do, the CLI command would be neat still :)

jhrdt commented 3 years ago

Hej,

Could you assign the issue to me?

PonteIneptique commented 3 years ago

Here you go ! (I assume you meant this issue, not the future one)

jhrdt commented 3 years ago

Here you go ! (I assume you meant this issue, not the future one)

Yes, this one. Thanks

PonteIneptique commented 5 months ago

Done by #218