From 034e463b504093b70770d77b1058744e7f1bab06 Mon Sep 17 00:00:00 2001 From: erickson Date: Sun, 16 Sep 2007 17:43:09 +0000 Subject: [PATCH] added a login method git-svn-id: svn://svn.open-ils.org/ILS/trunk@7792 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/python/oils/utils/utils.py | 34 +++++++++++++++++++------ 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/python/oils/utils/utils.py b/Open-ILS/src/python/oils/utils/utils.py index 47df3f7d1e..42d6e890c9 100644 --- a/Open-ILS/src/python/oils/utils/utils.py +++ b/Open-ILS/src/python/oils/utils/utils.py @@ -14,19 +14,14 @@ # ----------------------------------------------------------------------- import re, md5 +from osrf.ses import osrfAtomicRequest +from osrf.log import * -# ----------------------------------------------------------------------- -# Grab-bag of general utility functions -# ----------------------------------------------------------------------- - # ----------------------------------------------------------------------- -# more succinct search/replace call +# Grab-bag of general utility functions # ----------------------------------------------------------------------- -def replace(str, pattern, replace): - return re.compile(pattern).sub(replace, str) - def isEvent(evt): return (evt and isinstance(evt, dict) and evt.get('ilsevent') != None) @@ -54,3 +49,26 @@ def unique(arr): o[x] = 1 return o.keys() + +def login(username, password, type=None, workstation=None): + ''' Login to the server and get back an authtoken''' + + osrfLogInfo("attempting login with user " + username) + + seed = osrfAtomicRequest( + 'open-ils.auth', + 'open-ils.auth.authenticate.init', username) + + # generate the hashed password + password = md5sum(seed + md5sum(password)) + + return osrfAtomicRequest( + 'open-ils.auth', + 'open-ils.auth.authenticate.complete', + { 'workstation' : workstation, + 'username' : username, + 'password' : password, + 'type' : type + } + ) + -- 2.43.2