AuthorisationContext.vala 589 B

12345678910111213141516171819202122232425
  1. namespace Spry.Authorisation {
  2. public class AuthorisationContext : Object {
  3. public AuthorisationToken? token { get; private set; }
  4. public AuthorisationContext(AuthorisationToken? token = null) {
  5. this.token = token;
  6. }
  7. public bool has_permission(string permission = "*") {
  8. if(token == null){
  9. return false;
  10. }
  11. return token.permissions.any(p => PermissionMatcher.matches(permission, p));
  12. }
  13. public bool is_anonymous() {
  14. return token == null;
  15. }
  16. }
  17. }