public
Authored by
null pointer
jam.py server-side snippet for multiple local login sources
Edited
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def on_login(task, login, password):
results = None
if not results and login == "admin" and password == "admin":
results = {
'user_id': '1',
'user_name': 'administrative failsafe',
'role_id': 1,
'role_name': 'Administrator',
'admin': 1
}
print("DEV: hardcoded login")
if not results:
user = task.catalogs.external.copy()
user.open(where = {
"f_login": login,
"f_password": password })
if user.record_count() == 1:
# match role_id and role_name with existing system roles
results = {
'user_id': user.field_by_name('id').value,
'user_name': user.field_by_name('username').value,
'role_id': 2,
'role_name': 'Lesser Group',
'admin': 0,
'custom_field': user.field_by_name('custom_field').value
}
print("DEV: login via userspace")
if not results:
user = task.app.admin.sys_catalogs.sys_users.copy()
user.open(where = {
"f_login": login,
"f_password": password })
if user.record_count() == 1:
results = {
'user_id': user.field_by_name('id').value,
'user_name': user.field_by_name('f_name').value,
'role_id': user.field_by_name('f_role').value,
'role_name': user.field_by_name('f_role').display_text,
'admin': user.field_by_name('f_admin').value
}
print("DEV: login via system")
return results
Please register or sign in to comment