Test and update the media-types docs with Debian 10 and CentOS.
[mediagoblin.git] / mediagoblin / auth / __init__.py
index 2460c048ef05f17e70b99a3dc37e7525b391d6ac..f518a09d5ed9a75d9c42eee73d20accfe77a21a4 100644 (file)
 #
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
-from mediagoblin.tools.pluginapi import hook_handle
+from mediagoblin.tools.pluginapi import hook_handle, hook_runall
 
 
-def check_login(user, login_form):
-    return hook_handle("auth_check_login", user, login_form)
+def get_user(**kwargs):
+    """ Takes a kwarg such as username and returns a user object """
+    return hook_handle("auth_get_user", **kwargs)
 
 
-def get_user(*args):
-    return hook_handle("auth_get_user", *args)
+def create_user(register_form):
+    results = hook_runall("auth_create_user", register_form)
+    return results[0]
 
+def extra_validation(register_form):
+    from mediagoblin.auth.tools import basic_extra_validation
 
-def create_user(*args):
-    return hook_handle("auth_create_user", *args)
+    extra_validation_passes = basic_extra_validation(register_form)
+    if False in hook_runall("auth_extra_validation", register_form):
+        extra_validation_passes = False
+    return extra_validation_passes
 
 
-def extra_validation(register_form, *args):
-    return hook_handle("auth_extra_validation", register_form, *args)
+def gen_password_hash(raw_pass, extra_salt=None):
+    return hook_handle("auth_gen_password_hash", raw_pass, extra_salt)
 
 
-def get_user_metadata(user):
-    return hook_handle("auth_get_user_metadata", user)
-
-
-def get_login_form(request):
-    return hook_handle("auth_get_login_form", request)
-
-
-def get_registration_form(request):
-    return hook_handle("auth_get_registration_form", request)
+def check_password(raw_pass, stored_hash, extra_salt=None):
+    return hook_handle("auth_check_password",
+                       raw_pass, stored_hash, extra_salt)