- can [:show, :download, :query], Changeset
- can [:index, :create, :comment, :feed, :show, :search], Note
- can :index, Tracepoint
- can [:index, :show], User
- can [:index, :show], Node
- can [:index, :show, :full, :ways_for_node], Way
- can [:index, :show, :full, :relations_for_node, :relations_for_way, :relations_for_relation], Relation
- can [:history, :version], OldNode
- can [:history, :version], OldWay
- can [:history, :version], OldRelation
- can [:show], UserBlock
- end
+ user = User.find(token.resource_owner_id) if token
+
+ can [:read, :feed, :search], Note
+ can :create, Note unless token
+
+ can [:read, :download], Changeset
+ can :read, Tracepoint
+ can :read, User
+ can :read, Node
+ can [:read, :full, :ways_for_node], Way
+ can [:read, :full, :relations_for_node, :relations_for_way, :relations_for_relation], Relation
+ can [:history, :read], [OldNode, OldWay, OldRelation]
+ can :read, UserBlock
+
+ if user&.active?
+ can [:create, :comment, :close, :reopen], Note if scope?(token, :write_notes)
+ can [:create, :destroy], NoteSubscription if scope?(token, :write_notes)
+
+ can :read, Trace if scope?(token, :read_gpx)
+ can [:create, :update, :destroy], Trace if scope?(token, :write_gpx)
+
+ can :details, User if scope?(token, :read_prefs)
+ can :gpx_files, User if scope?(token, :read_gpx)