mozilla/openbadges-badgekit — pull request #271 by christensenep (2014-03-18 21:51:20+00:00)
Title: [WIP, sorta] Initial account stuff

This adds user accounts to badgekit. User accounts can have permissions with respect to one or more contexts (each of which specifies a system, program and issuer, the latter two being optional). Currently view permission is always granted if the user has permissions of any kind for a given context, and additionally the user can be given permission to add drafts and/or publish badges in that context.

Permissions in multiple contexts don't work wonderfully at the moment. The permissions themselves work correctly, but since badgekit doesn't currently have good feedback on what context you are working in (and doesn't allow you to change the programs/systems/issuers that a badge belongs to), having multiple permissions will result in new badges being created in an arbitrary context that you have permissions for, with no easy way of seeing which one that is. So we probably shouldn't have users with multiple permissions at the moment.

There also appears to be a bug in badgekit-issue-client that I discovered while working on this. It causes a crash if a user with system-level permissions tries to fetch data of a published badge that belongs to a program. Basically what this means is that if any program-level badges exist in badgekit-issue, badgekit will crash if a user with system-level permissions ever sees that badge (even just seeing it in a directory view). This can be worked around for the time being by simply not creating any program-level permissions, but I'll look into fixing the bug ASAP.