Merge pull request #1967 from misl6/master
Fixes login_bare + register_bare w/ custom login_userfield
This commit is contained in:
@@ -103,17 +103,18 @@ class CacheRepresenter(object):
|
||||
cache[field][value] = nvalue
|
||||
return nvalue
|
||||
|
||||
|
||||
def safe_int(x, i=0):
|
||||
try:
|
||||
return int(x)
|
||||
except ValueError:
|
||||
except (ValueError, TypeError):
|
||||
return i
|
||||
|
||||
|
||||
def safe_float(x):
|
||||
try:
|
||||
return float(x)
|
||||
except ValueError:
|
||||
except (ValueError, TypeError):
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
@@ -775,8 +775,8 @@ class Mail(object):
|
||||
if attachments:
|
||||
result = mail.send_mail(
|
||||
sender=sender, to=origTo,
|
||||
subject=to_unicode(subject, encoding),
|
||||
body=to_unicode(text or '', encoding),
|
||||
subject=to_unicode(subject, encoding),
|
||||
body=to_unicode(text or '', encoding),
|
||||
html=html,
|
||||
attachments=attachments, **xcc)
|
||||
elif html and (not raw):
|
||||
@@ -794,7 +794,7 @@ class Mail(object):
|
||||
try:
|
||||
raw = {'Data': payload.as_string()}
|
||||
response = client.send_raw_email(RawMessage=raw,
|
||||
Source=sender,
|
||||
Source=sender,
|
||||
Destinations=to)
|
||||
return True
|
||||
except ClientError as e:
|
||||
@@ -2161,7 +2161,10 @@ class Auth(AuthAPI):
|
||||
user = None
|
||||
checks = []
|
||||
# make a guess about who this user is
|
||||
for fieldname in ['registration_id', 'username', 'email']:
|
||||
guess_fields = ['registration_id', 'username', 'email']
|
||||
if self.settings.login_userfield:
|
||||
guess_fields.append(self.settings.login_userfield)
|
||||
for fieldname in guess_fields:
|
||||
if fieldname in table_user.fields() and \
|
||||
keys.get(fieldname, None):
|
||||
checks.append(fieldname)
|
||||
@@ -2255,7 +2258,8 @@ class Auth(AuthAPI):
|
||||
def _get_login_settings(self):
|
||||
table_user = self.table_user()
|
||||
userfield = self.settings.login_userfield or 'username' \
|
||||
if 'username' in table_user.fields else 'email'
|
||||
if self.settings.login_userfield or 'username' \
|
||||
in table_user.fields else 'email'
|
||||
passfield = self.settings.password_field
|
||||
return Storage({'table_user': table_user,
|
||||
'userfield': userfield,
|
||||
@@ -3630,7 +3634,7 @@ class Auth(AuthAPI):
|
||||
onaccept = self.settings.profile_onaccept
|
||||
if log is DEFAULT:
|
||||
log = self.messages['profile_log']
|
||||
|
||||
|
||||
form = SQLFORM(
|
||||
table_user,
|
||||
self.user.id,
|
||||
|
||||
@@ -943,9 +943,7 @@ def console():
|
||||
k = len(sys.argv)
|
||||
sys.argv, other_args = sys.argv[:k], sys.argv[k + 1:]
|
||||
(options, args) = parser.parse_args()
|
||||
options.args = other_args
|
||||
if options.run:
|
||||
options.args.insert(0, options.run)
|
||||
options.args = [options.run] + other_args
|
||||
|
||||
copy_options = copy.deepcopy(options)
|
||||
copy_options.password = '******'
|
||||
|
||||
Reference in New Issue
Block a user