Allow administration through email

This commit is contained in:
RunasSudo 2018-08-23 14:31:58 +10:00
parent 05d5650f2f
commit 4bc3fcf30c
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 18 additions and 8 deletions

View File

@ -448,13 +448,21 @@ def email_login():
def email_authenticate(): def email_authenticate():
user = None user = None
for election in Election.get_all(): for u in app.config['ADMINS']:
for voter in election.voters: if isinstance(u, EmailUser):
if isinstance(voter.user, EmailUser): if u.email.lower() == flask.request.form['email'].lower():
if voter.user.email.lower() == flask.request.form['email'].lower(): if u.password == flask.request.form['password']:
if voter.user.password == flask.request.form['password']: user = u
user = voter.user break
break
if user is None:
for election in Election.get_all():
for voter in election.voters:
if isinstance(voter.user, EmailUser):
if voter.user.email.lower() == flask.request.form['email'].lower():
if voter.user.password == flask.request.form['password']:
user = voter.user
break
if user is None: if user is None:
return flask.render_template('auth/email/login.html', error='The email or password you entered was invalid. Please check your details and try again. If the issue persists, contact the election administrator.') return flask.render_template('auth/email/login.html', error='The email or password you entered was invalid. Please check your details and try again. If the issue persists, contact the election administrator.')

View File

@ -9,9 +9,11 @@ AUTH_METHODS = [
('reddit', 'Reddit') ('reddit', 'Reddit')
] ]
import eos.base.election
import eos.redditauth.election import eos.redditauth.election
ADMINS = [ ADMINS = [
#eos.redditauth.election.RedditUser(username='xxxxxxxx') #eos.redditauth.election.RedditUser(username='xxxxxxxx'),
#eos.base.election.EmailUser(email='xxxxx@example.com', password='abc123'),
] ]
TASK_RUN_STRATEGY = 'eos.core.tasks.direct.DirectRunStrategy' TASK_RUN_STRATEGY = 'eos.core.tasks.direct.DirectRunStrategy'