from mediagoblin.tools.pluginapi import hook_handle, hook_runall
-def get_user(username):
- return hook_handle("auth_get_user", username)
+def get_user(**kwargs):
+ """ Takes a kwarg such as username and returns a user object """
+ return hook_handle("auth_get_user", **kwargs)
def create_user(register_form):
def check_login_simple(username, password):
- user = auth.get_user(username)
+ user = auth.get_user(username=username)
if not user:
_log.info("User %r not found", username)
auth.fake_login_attempt()
config = pluginapi.get_config('mediagoblin.pluginapi.basic_auth')
-def get_user(username):
- user = User.query.filter(
- or_(
- User.username == username,
- User.email == username,
- )).first()
- return user
+def get_user(**kwargs):
+ username = kwargs.pop('username', None)
+ if username:
+ user = User.query.filter(
+ or_(
+ User.username == username,
+ User.email == username,
+ )).first()
+ return user
def create_user(registration_form):
- user = get_user(registration_form.username.data)
+ user = get_user(username=registration_form.username.data)
if not user and 'password' in registration_form:
user = User()
user.username = registration_form.username.data