11USER_MUST_CHANGE_PASSWORD = 0x01
13USER_NEED_APPROVAL = 0x04
15USER_CAN_MANAGE_SELF = 0x10
34 """User accounts for the system. Handles logins, uploads, storage
35 quotas, access tokens, and the such.
37 Pafera adds a place field to the traditional username/password
38 combination, both
for added security
and to allow different places
39 to use the same phone number
for their own accounts. It
's the
40 unique combination of (phonenumber, place, password) that
41 identifies a particular user.
43 Note that displayname is a translation field, meaning that that
44 a user can have their own names
in different languages.
46 expiredate
is when the user account will expire. Set it far into
47 the future
for your own administrator account.
49 canmanage
and managedby are used
for managed accounts such
as
50 students being managed by a teacher. Managed accounts cannot
51 change anything besides change their own password.
53 accesstokens are used by the system to allow APIs to assume the
54 identity of a user. The APIs used must be explicitly specified
for
55 the token to work. The token format
is a dict such
as
58 "expiredate": timestamp,
60 '/system/fileapi:search',
61 '/system/fileapi:load',
62 '/system/fileapi:save'
68 'rid': (
'INTEGER PRIMARY KEY',
'NOT NULL',),
72 'email': (
'TEXT',
"NOT NULL DEFAULT ''",),
74 'settings': (
'DICT',
"NOT NULL DEFAULT ''",),
75 'expiredate': (
'DATETIME',
"NOT NULL DEFAULT 0",),
76 'storageused': (
'BIGINT',
"NOT NULL DEFAULT 0",),
77 'storagequota': (
'BIGINT',
"NOT NULL DEFAULT 134217728",),
78 'numcanmmanage': (
'INT',
"NOT NULL DEFAULT 0",),
79 'canmanage': (
'NEWLINELIST',
"NOT NULL DEFAULT ''",),
80 'managedby': (
'NEWLINELIST',
"NOT NULL DEFAULT ''",),
81 'accesstokens': (
'DICT',
"NOT NULL DEFAULT ''",),
82 'flags': (
'INT',
'NOT NULL DEFAULT 0',),
85 (
'unique', (
'phonenumber',
'place')),
87 _dblinks = [
'system_group',
'system_user']
88 _dbdisplay = [
'place',
'displayname',
'phonenumber']
92G.displayfuncs['system_user'] = function(type, fields, item, ls, modellinks, data)
94 let modelid = G.modelids['system_user'];
95 let modelinfo = G.modelfields[
'system_user'];
100 ls.push(`<div
class=
"blueg Center">${item[
'rid']} (${idcode})</div>
102 ${P.HeadShotImg(idcode,
'Square600')}<br>
107 ls.push(`<th
class=
"Center">
108 ${P.HeadShotImg(idcode,
'Square600')}<br>
109 ${item[
'rid']} (${idcode})
113 for (let j = 1, m = fields.length; j < m; j++)
118 let valuetype = modelinfo[k][0];
122 if (valuetype ==
'JSON')
124 ls.push(
'<pre>' + JSON.stringify(value, null, 2) +
'</pre>');
125 }
else if (valuetype.indexOf(
'TRANSLATION') != -1)
127 ls.push(
'<div>' + P.BestTranslation(value) +
'</div>');
130 ls.push(
'<div>' + value +
'</div>');
134 if (valuetype ==
'JSON')
136 ls.push(
'<td>' + JSON.stringify(value, null, 2) +
'</td>');
137 }
else if (valuetype.indexOf(
'TRANSLATION') != -1)
139 ls.push(
'<td>' + P.BestTranslation(value) +
'</td>');
142 ls.push(
'<td>' + value +
'</td>');
Base class for all database models.
Throws an exception on blank values.
User accounts for the system.
def __init__(self)
Initialize all fields at creation like a good programmer should.
def ToShortCode(val, chars='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_')
Turns a 32-bit value into a six character alphanumeric code.