|
@@ -29,6 +29,7 @@ class Client(object):
|
29
|
29
|
del(old)
|
30
|
30
|
logger.debug("Replacing old Client instance by a new one")
|
31
|
31
|
Client._instance = self
|
|
32
|
+ logger.debug("New client : %s" % self)
|
32
|
33
|
|
33
|
34
|
# Instanciation done. Triggering Auth instanciation
|
34
|
35
|
self.__auth = Auth(self)
|
|
@@ -57,6 +58,18 @@ class Client(object):
|
57
|
58
|
instance exists")
|
58
|
59
|
return cls._instance
|
59
|
60
|
|
|
61
|
+ ##@brief Alias of Client::destroy()
|
|
62
|
+ @classmethod
|
|
63
|
+ def deauth(cls):
|
|
64
|
+ cls.destroy()
|
|
65
|
+
|
|
66
|
+ ##@brief Destroy current client
|
|
67
|
+ @classmethod
|
|
68
|
+ def destroy(cls):
|
|
69
|
+ inst = cls._instance
|
|
70
|
+ cls._instance = None
|
|
71
|
+ del(inst)
|
|
72
|
+
|
60
|
73
|
##@brief Authenticate using login an password
|
61
|
74
|
#@note Wrapper on Auth.auth()
|
62
|
75
|
#@param login str
|
|
@@ -160,20 +173,24 @@ class Auth(object):
|
160
|
173
|
# Singleton
|
161
|
174
|
if self._instance is not None:
|
162
|
175
|
bck = self._instance
|
|
176
|
+ bck.destroy()
|
163
|
177
|
self._instance = None
|
164
|
|
- del(bck)
|
165
|
178
|
logger.debug("Previous Auth instance replaced by a new one")
|
166
|
179
|
else:
|
167
|
180
|
#First instance, fetching settings
|
168
|
181
|
self.fetch_settings()
|
169
|
182
|
self.__class__._instance = self
|
170
|
|
-
|
171
|
|
- ##@brief Instance destructor
|
172
|
|
- def __del__(self):
|
|
183
|
+
|
|
184
|
+ ##@brief Destroy current instance an associated session
|
|
185
|
+ def _destroy(self):
|
173
|
186
|
self.__user_infos = LodelHook.call_hook('lodel2_session_destroy',
|
174
|
|
- caller = self, payload = token) # TODO unresolved variable
|
175
|
|
- pass
|
|
187
|
+ caller = self, payload = self.__session_id)
|
176
|
188
|
|
|
189
|
+ ##@brief Destroy singleton instance
|
|
190
|
+ @classmethod
|
|
191
|
+ def destroy(cls):
|
|
192
|
+ cls._instance._destroy()
|
|
193
|
+
|
177
|
194
|
##@brief Raise exception because of authentication failure
|
178
|
195
|
#@note trigger a security log containing client infos
|
179
|
196
|
#@throw LodelFatalError if no instance exsists
|
|
@@ -194,20 +211,25 @@ class Auth(object):
|
194
|
211
|
#Allready fetched
|
195
|
212
|
return
|
196
|
213
|
infos = (
|
197
|
|
- Settings.auth.login_classfield.split('.'),
|
198
|
|
- Settings.auth.pass_classfield.split('.'))
|
|
214
|
+ Settings.auth.login_classfield,
|
|
215
|
+ Settings.auth.pass_classfield)
|
199
|
216
|
res_infos = []
|
200
|
217
|
for clsname, fieldname in infos:
|
|
218
|
+<<<<<<< HEAD
|
201
|
219
|
res_infos.append((
|
202
|
220
|
dyncode.lowername2class(infos[0]),
|
203
|
221
|
dcls.field(infos[1]))) # TODO cls.field ?
|
|
222
|
+=======
|
|
223
|
+ dcls = dyncode.lowername2class(infos[0][0])
|
|
224
|
+ res_infos.append((dcls, infos[1][1]))
|
|
225
|
+>>>>>>> Plug webui to auth
|
204
|
226
|
|
205
|
227
|
link_field = None
|
206
|
|
- if res_infos[0][0] != res_infos[0][1]:
|
|
228
|
+ if res_infos[0][0] != res_infos[1][0]:
|
207
|
229
|
# login and password are in two separated EmClass
|
208
|
230
|
# determining the field that links login EmClass to password
|
209
|
231
|
# EmClass
|
210
|
|
- for fname, fdh in res_infos[0][0].fields(True):
|
|
232
|
+ for fname, fdh in res_infos[0][0].fields(True).items():
|
211
|
233
|
if fdh.is_reference() and res_infos[1][0] in fdh.linked_classes():
|
212
|
234
|
link_field = fname
|
213
|
235
|
if link_field is None:
|
|
@@ -243,7 +265,7 @@ login EmClass '%s' and password EmClass '%s'. Abording..." % (
|
243
|
265
|
login_cls = infos['login'][0]
|
244
|
266
|
pass_cls = infos['pass'][0]
|
245
|
267
|
qfilter = "passfname = passhash"
|
246
|
|
- uid_fname = login_cls.uid_fieldname()[0] #COMPOSED UID BROKEN
|
|
268
|
+ uid_fname = login_cls.uid_fieldname()[0] #COMPOSED UID BROKEN
|
247
|
269
|
if login_cls == pass_cls:
|
248
|
270
|
#Same EmClass for login & pass
|
249
|
271
|
qfilter = qfilter.format(
|