Compare commits

..

No commits in common. "24322588d706c725ce790282013a5d3016f713cc" and "78729c611134d02496d899c522929f4797a20655" have entirely different histories.

6 changed files with 79 additions and 128 deletions

View file

@ -16240,7 +16240,11 @@ var lib_plankton;
"name": (data["preferred_username"] ?? null), "name": (data["preferred_username"] ?? null),
"label": (data["name"] ?? null), "label": (data["name"] ?? null),
"email": (data["email"] ?? null), "email": (data["email"] ?? null),
"groups": (data["groups"] ?? null), "groups": (((data["groups"] === undefined) || (data["groups"] === null))
?
null
:
data["groups"].split(",")),
}); });
} }
/** /**

View file

@ -122,6 +122,8 @@ namespace _zeitbild.api
); );
} }
else else
{
try
{ {
// groups // groups
const group_ids : Array<_zeitbild.type_group_id> = await Promise.all<_zeitbild.type_group_id>( const group_ids : Array<_zeitbild.type_group_id> = await Promise.all<_zeitbild.type_group_id>(
@ -129,13 +131,19 @@ namespace _zeitbild.api
.map( .map(
async (group_name_raw) => { async (group_name_raw) => {
const group_name : string = get_group_name(group_name_raw); const group_name : string = get_group_name(group_name_raw);
const group_id_raw : (null | _zeitbild.type_group_id) = await ( let group_id : (null | _zeitbild.type_group_id) = await (() => {
_zeitbild.repository.group.identify(group_name) try
.catch(() => Promise.resolve(null))
);
if (group_id_raw === null)
{ {
const group_id : _zeitbild.type_group_id = await _zeitbild.service.group.add( return _zeitbild.repository.group.identify(group_name);
}
catch (error)
{
return Promise.resolve(null);
}
}) ();
if (group_id === null)
{
group_id = await _zeitbild.service.group.add(
{ {
"name": group_name, "name": group_name,
"label": get_group_label(group_name_raw), "label": get_group_label(group_name_raw),
@ -145,7 +153,6 @@ namespace _zeitbild.api
} }
else else
{ {
const group_id : _zeitbild.type_group_id = group_id_raw;
await _zeitbild.service.group.change( await _zeitbild.service.group.change(
group_id, group_id,
{ {
@ -158,52 +165,25 @@ namespace _zeitbild.api
} }
) )
); );
await _zeitbild.service.user.add(
const user_id : _zeitbild.type_user_id = await (async () => { {
const user_object : _zeitbild.type_user_object = { "name": data.userinfo.name,
"name": (data.userinfo.name as string),
"groups": group_ids, "groups": group_ids,
"email_address": data.userinfo.email, "email_address": data.userinfo.email,
"dav_token": null, "dav_token": null,
}; }
const user_id_raw : (null | _zeitbild.type_user_id) = await (
_zeitbild.service.user.identify(data.userinfo.name as string)
.catch(() => Promise.resolve(null))
);
if (user_id_raw === null)
{
// provision
const user_id : _zeitbild.type_user_id = await _zeitbild.service.user.add(
user_object
); );
lib_plankton.log.info( lib_plankton.log.info(
"user_provisioned", "user_provisioned",
{ {
"id": user_id, "name": data.userinfo.name,
"name": user_object.name,
} }
); );
return user_id;
} }
else catch (error)
{ {
const user_id : _zeitbild.type_user_id = user_id_raw; // do nothing
// update
await _zeitbild.service.user.change(
user_id,
user_object
);
lib_plankton.log.info(
"user_updated",
{
"id": user_id,
"name": user_object.name,
} }
);
return user_id;
}
}) ();
const session_key : string = await lib_plankton.session.begin( const session_key : string = await lib_plankton.session.begin(
data.userinfo.name, data.userinfo.name,
{ {

View file

@ -100,7 +100,6 @@ namespace _zeitbild.auth
"openid", "openid",
"profile", "profile",
"email", "email",
"groups",
], ],
"label": _zeitbild.conf.get().authentication.data.label, "label": _zeitbild.conf.get().authentication.data.label,
} }

View file

@ -639,62 +639,31 @@ namespace _zeitbild.repository.calendar
(x : Array<Record<string, any>>) => x.map( (x : Array<Record<string, any>>) => x.map(
(row : Record<string, any>) => ({ (row : Record<string, any>) => ({
"id": row["id"], "id": row["id"],
"name": lib_plankton.call.convey( "name": row["name"],
row["name"], "hue": (row["hue"] / hue_scaling),
[
// JSON.parse,
(x : Array<string>) => x[0],
]
),
"hue": lib_plankton.call.convey(
row["hue"],
[
// JSON.parse,
(x : Array<int>) => x[0],
(x : int) => (x / hue_scaling),
]
),
/** /**
* @todo use _zeitbild.access_level_determine * @todo use _zeitbild.access_level_determine
*/ */
"access_level": _zeitbild.access_level_determine_raw( "access_level": _zeitbild.access_level_determine_raw(
lib_plankton.call.convey(
row["access_public"], row["access_public"],
[
// JSON.parse,
(x : Array<boolean>) => x[0],
]
),
( (
(user_id === null) (user_id === null)
? ?
null null
: :
{ {
"default": lib_plankton.call.convey( "default": decode_access_level(row["access_level_default"]),
row["access_level_default"], "group": (
[ lib_plankton.call.null_prop<string, Array<_zeitbild.enum_access_level>>(
// JSON.parse,
(x : Array<int>) => x[0],
decode_access_level,
]
),
"group": lib_plankton.call.convey(
row["access_level_attributed_group"], row["access_level_attributed_group"],
[ x => x.split(",").map(parseInt).map(decode_access_level)
// JSON.parse, )
(x : Array<(null | int)>) => x.filter(y => (y !== null)), ??
(x : Array<int>) => x.map(decode_access_level), []
]
), ),
"user": lib_plankton.call.convey( "user": lib_plankton.call.null_prop<int, _zeitbild.enum_access_level>(
row["access_level_attributed_user"], row["access_level_attributed_user"],
[ decode_access_level
// JSON.parse,
(x : Array<(null | int)>) => x.filter(y => (y !== null)),
(x : Array<int>) => x.map(decode_access_level),
(x : Array<_zeitbild.enum_access_level>) => ((x.length > 0) ? x[0] : null),
]
), ),
} }
) )

View file

@ -1,11 +1,11 @@
SELECT SELECT
x.id AS id, x.id AS id,
JSON_AGG(x.name) AS name, MAX(x.name) AS name,
JSON_AGG(x.hue) AS hue, MAX(x.hue) AS hue,
JSON_AGG(x.access_public) AS access_public, MAX(x.access_public) AS access_public,
JSON_AGG(x.access_level_default) AS access_level_default, MAX(x.access_level_default) AS access_level_default,
JSON_AGG(y1.level) AS access_level_attributed_group, GROUP_CONCAT(y1.level, ',') AS access_level_attributed_group,
JSON_AGG(y2.level) AS access_level_attributed_user GROUP_CONCAT(y2.level, ',') AS access_level_attributed_user
FROM FROM
calendars AS x calendars AS x
LEFT OUTER JOIN calendar_access_attributed_group AS y1 ON ((x.id = y1.calendar_id) AND (y1.group_id IN (SELECT group_id FROM user_groups WHERE (user_id = $user_id)))) LEFT OUTER JOIN calendar_access_attributed_group AS y1 ON ((x.id = y1.calendar_id) AND (y1.group_id IN (SELECT group_id FROM user_groups WHERE (user_id = $user_id))))

View file

@ -47,7 +47,6 @@ def main():
"--verbose", "--verbose",
"--exclude='conf.json'", "--exclude='conf.json'",
"--exclude='data.sqlite'", "--exclude='data.sqlite'",
"--exclude='log.jsonl'",
("%s/" % args.build_directory), ("%s/" % args.build_directory),
( (
("%s" % args.target_directory) ("%s" % args.target_directory)