Allow administration through email
This commit is contained in:
parent
05d5650f2f
commit
4bc3fcf30c
@ -448,13 +448,21 @@ def email_login():
|
||||
def email_authenticate():
|
||||
user = 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
|
||||
for u in app.config['ADMINS']:
|
||||
if isinstance(u, EmailUser):
|
||||
if u.email.lower() == flask.request.form['email'].lower():
|
||||
if u.password == flask.request.form['password']:
|
||||
user = u
|
||||
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:
|
||||
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.')
|
||||
|
@ -9,9 +9,11 @@ AUTH_METHODS = [
|
||||
('reddit', 'Reddit')
|
||||
]
|
||||
|
||||
import eos.base.election
|
||||
import eos.redditauth.election
|
||||
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'
|
||||
|
Loading…
Reference in New Issue
Block a user