mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 17:17:09 +00:00
#920 step2 refactor addPermissions method
This commit is contained in:
parent
2d0ed7de6f
commit
44ac14f32d
@ -126,14 +126,8 @@ object MapperViews extends Views with MdcLoggable {
|
||||
} else {
|
||||
viewImpls.foreach(v => {
|
||||
if(v.isPublic && !ALLOW_PUBLIC_VIEWS) return Failure(PublicViewsNotAllowedOnThisInstance)
|
||||
if (ViewPrivileges.count(By(ViewPrivileges.user, user.resourceUserId.value), By(ViewPrivileges.view, v.id)) == 0) {
|
||||
ViewPrivileges.create.
|
||||
user(user.resourceUserId.value).
|
||||
view(v.id).
|
||||
save
|
||||
}
|
||||
getOrCreateViewPrivilege(user, v)
|
||||
})
|
||||
//TODO: this doesn't handle the case where one viewImpl fails to be saved
|
||||
Full(viewImpls)
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,6 +26,8 @@ trait Views {
|
||||
def permissions(account : BankIdAccountId) : List[Permission]
|
||||
def permission(account : BankIdAccountId, user: User) : Box[Permission]
|
||||
def getOrCreateViewPrivilege(view: View, user: User): Box[View]
|
||||
// This is for ViewPrivileges. It will first find the view object by `viewIdBankIdAccountId`
|
||||
// And than, @getOrCreateViewPrivilege(view: View, user: User) for the view and user.
|
||||
def addPermission(viewIdBankIdAccountId : ViewIdBankIdAccountId, user : User) : Box[View]
|
||||
def addPermissions(views : List[ViewIdBankIdAccountId], user : User) : Box[List[View]]
|
||||
def revokePermission(viewIdBankIdAccountId : ViewIdBankIdAccountId, user : User) : Box[Boolean]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user